dataflow
dataflow copied to clipboard
Improve the await usage
Currently there are two variants of await, for finite and infinite flows:
-
await : ('i, 'o, 'i option) node– asks the user to match on optional input values. -
await_forever : ('i -> ('i, 'o, 'r) node) -> ('i, 'o, unit) node– assumes the stream is infinite, the user gets directly the input value.
It may be more practical to improve the usage of these two functions, the reason being that the infinite variant will used more frequently. The automatic termination of the flow by upstream in case of failures should be the default behaviour.
After the change the following two functions will exist:
-
await : ('i, 'o, 'i) node– provides the input as a direct monadic value.- Usage:
await >>= fun a -> ....
- Usage:
-
try_await : ('i, 'o, 'i option) node– gives the user the possibility to handle upstream termination.- Usage:
try_await >>= function Some a -> ... | None -> ...
- Usage: