flows
Nu2 Flow atoms: the Command-composing sub-kind.
Module nu.core.flows.
Nu2 Flow atoms: the Command-composing sub-kind.
- Strategy - compose mutating atoms directly:
Sequential(>>),Parallel(|),Race(&),Gather,AnyN.Parallelalso exposes forced-mode variantsParallelThreaded/ParallelAsyncfor explicit placement (Race / AnyN are async-only, no variants). - Control - compose bodies under Query parameters:
IfDo,WhileDo,ForeverDo,ForEachDo,ForEachParAsync,ForRangeDo,Delay,DelayedDo,SwitchDo.ForEachParAsyncis the fan-out ForEach: one arm per element on the loop, all at once, joining on all.
The flows driven by change subscriptions (React and the rest of the event
kind, ReconcileReactive and the rest of the level kind, Stream) live in
nu.core.reactive, next to the subscriptions they consume.
parallel.anyn
Module nu.core.flows.parallel.anyn.
AnyN: first-to-succeed fan-in over the async loop.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| AnyN | strategy | AnyN(*children) | Runs its children concurrently; succeeds as soon as any one does. |
control
Module nu.core.flows.control.
Control flows: Command-composing atoms steered by Query parameters.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| Delay | control | Delay(seconds) | Delay(seconds) - sleeps seconds, then continues. No body. |
| DelayedDo | control | DelayedDo(delay, body) | DelayedDo(delay, body) - sleeps delay seconds, then runs body. |
| ForEachDo | control | ForEachDo(items, body, item=None) | ForEachDo(items, lambda x: body) - runs body once per element of items. |
| ForEachParAsync | control | ForEachParAsync(items, body, item=None) | ForEachParAsync(items, lambda x: body) - runs body once per element of items, every arm on the loop at once. |
| ForRangeDo | control | ForRangeDo(start, stop, body, step=1, index=None) | ForRangeDo(start, stop, lambda i: body, *, step=1) - runs body once per value of range(start, stop, step). |
| ForeverDo | control | ForeverDo(body) | ForeverDo(body) - runs body on loop forever. |
| IfDo | control | IfDo(cond, then, else_=None) | IfDo(cond, then, else_=None) - runs then or else_ based on cond. |
| SwitchDo | control | SwitchDo(selector, cases, default=None) | SwitchDo(selector, cases, default=None) - runs the case body keyed by selector's value. |
| WhileDo | control | WhileDo(cond, body) | WhileDo(cond, body) - runs body on loop while cond stays truthy. |
parallel.parallel
Module nu.core.flows.parallel.parallel.
Parallel: join-on-all fan-in, smart + forced variants.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| Gather | strategy | Gather(*items) | Alias of Parallel, named for reading naturally at a yield site. |
| Parallel | strategy | Parallel(*items) | Runs its children concurrently and joins once every one has finished. |
| ParallelAsync | strategy | ParallelAsync(*items) | Parallel with every child forced onto the loop under async. |
| ParallelThreaded | strategy | ParallelThreaded(*items) | Parallel with every child forced onto a worker thread under async. |
noop
Module nu.core.flows.noop.
Noop: the empty Flow - the identity of flow composition.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| Noop | strategy | Noop() | The empty Flow: composes nothing, the identity of flow composition. |
parallel.race
Module nu.core.flows.parallel.race.
Race: first-to-complete fan-in over the async loop.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| Race | strategy | Race(*children) | Runs its children concurrently; first to finish wins - the & composition. |
raise_
Module nu.core.flows.raise_.
Raise: raise an exception at run time.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| Raise | control | Raise(msg, exc_cls=RuntimeError) | Raise exc_cls(msg) at run time. |
| raise_ | flows.raise_(exc_cls, msg) | Build a Raise node. Wrap in IfDo to gate. |
strategy
Module nu.core.flows.strategy.
Strategy flows: Command-composing atoms that dispatch their children.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| Sequential | strategy | Sequential(*children) | Runs its children in order - the >> composition. |