HttpRequestsAsTheyComplete

An input range that runs waitForFirstToComplete but only returning each request once. Before you loop over it, you can set some properties to customize behavior.

If it times out or is interrupted, it will prematurely run empty. You can set the delegate to process this.

Implementation note: each iteration through the loop does a O(n) check over each item remaining. This shouldn't matter, but if it does become an issue for you, let me know.

Constructors

this
this(Duration timeout, HttpRequest[] requests)

Seeds it with an overall timeout and the initial requests. It will send all the requests before returning, then will process the responses as they come.

Members

Functions

appendRequest
void appendRequest(HttpRequest request)

Adds another request to the work queue. It is safe to call this from inside the loop as you process other requests.

popFront
void popFront()

Standard range primitives. I reserve the right to change the variables to read-only properties in the future without notice.

reenter
bool reenter()

If the loop exited, it might be due to an interruption or a time out. If you like, you can call this to pick up the work again,

Variables

empty
bool empty;

Standard range primitives. I reserve the right to change the variables to read-only properties in the future without notice.

front
HttpRequest front;

Standard range primitives. I reserve the right to change the variables to read-only properties in the future without notice.

onInterruption
bool delegate() onInterruption;

You can set this delegate to decide how to handle an interruption. Returning true from this will keep working. Returning false will terminate the loop.

timeout
Duration timeout;

The timeout you set in the constructor. You can change it if you want.

Meta

History

Added December 24, 2021 (dub v10.5)