Creates a task routing each item to one of two tasks, according to a condition.
Each item is tested once and handed to a single task: the first one if it meets the condition, the second one
otherwise. The items both tasks report are interleaved into a single feed, each one as soon as it is ready.
Warning
Incremental: items are emitted as the tasks report them, until the source and both tasks run dry.
Streaming: one item is on offer at a time and none is retained, whatever the tasks retain.
Stateless: each item is routed on its own, whatever state the tasks carry.
Warning
Output order is not preserved: the items of the two tasks interleave and overtake each other according to how long
each task takes, though the items of each task keep their own order among themselves.
Caution
The two tasks draw in lockstep, so a task idling while still running holds back the other one: pacing and
long-running work belong downstream of the routing. A task closing early or running dry stops holding back the
other one, while a task that keeps running without ever drawing its feed stalls the routing for good.
Note
Each task is invoked once and handed only the items routed to it, so state it initialises on invocation decides
on that share alone: a quota or a deduplication covers the items meeting the condition, or the others.
Note
A failure of the condition or of either task is reported by the routed feed when it is next advanced.
Note
Both tasks and the source are closed when the feed is exhausted, fails or is closed early. Closing waits for the
work in flight to settle, so a source idling between items delays it; errors raised while closing are suppressed.
Creates a task routing each item to one of two tasks, according to a condition.
Each item is tested once and handed to a single task: the first one if it meets the condition, the second one otherwise. The items both tasks report are interleaved into a single feed, each one as soon as it is ready.
Output order is not preserved: the items of the two tasks interleave and overtake each other according to how long each task takes, though the items of each task keep their own order among themselves.
The two tasks draw in lockstep, so a task idling while still running holds back the other one: pacing and long-running work belong downstream of the routing. A task closing early or running dry stops holding back the other one, while a task that keeps running without ever drawing its feed stalls the routing for good.
Each task is invoked once and handed only the items routed to it, so state it initialises on invocation decides on that share alone: a quota or a deduplication covers the items meeting the condition, or the others.
A failure of the condition or of either task is reported by the routed feed when it is next advanced.
Both tasks and the source are closed when the feed is exhausted, fails or is closed early. Closing waits for the work in flight to settle, so a source idling between items delays it; errors raised while closing are suppressed.