Flow Guide Getting started The flow library enables a strict separation application logic from the deployment concerns of topology, execution, communication, lifecycle, monitoring and error handling. Step fns and process launchers You provide logic to flow in the form of step-fns, which are wrapped into running processes, executing in a loop. Flow manages the life cycle of the process and handles incoming and outgoing messages by putting or taking them on channels. Step-fns do not access channels directly or hold state, making them easy to test in isolation and reuse. Step functions have four arities: describe: (step-fn) -> descriptor The describe arity must return a static description of the step-fn’s :params, :ins, and :outs. Each of these is a map of name (a keyword) to docstring. For example, the describe arity might return this description for a simple step-fn: {:params {:size "Max size"} ;; step-fn params :ins {:in "Input channel"} ;; input channels :outs {:out "Output channel"}} ;; output channels The names used for input and output channels should be distinct (no overlap). init: (step-fn arg-map) -> init-state The init arity is called once by the process to takes a set of args from the flow def (corresponding to the params returned from the describe arity) and returns the init state of the process. transition: (step-fn state transition) -> state' The transition arity is called any time the flow or process undergoes a lifecycle transition (::flow/start, ::flow/stop, ::flow/pause, ::flow/resume). The description arity takes the current state and returns an updated state to be used for subsequent calls. The step-fn should use the transition arity to coordinate the creation, pausing, and shutdown of external resources in a process. transform: (step-fn state input msg) -> [state' {out-id [msgs]}] The transform arity is called in a loop by the process for every message received on an input channel and returns a new state and a map of output cids to messages to ret...
First seen: 2025-08-18 01:39
Last seen: 2025-08-18 08:40