Workflows4s Anatomy
What Does It Do?
Workflows4s enables the creation of workflows using the WIO
data type. A workflow built with WIO
supports the
following operations, as through the Workflow Elements:
- Running side-effectful computations
- Receiving signals from the external world
- Querying workflow state at any time
- Recovering workflow state without re-triggering side-effecting operations
WIO
is a pure value object that describes the workflow. However, to execute it, you need a runtime
capable of:
- Persisting events in a journal
- Reading events from the journal
How Does It Work?
First Run
- The workflow executes
IO
s along its path. EachIO
produces an event that is persisted in the journal. - Event handlers can modify the workflow state based on the events.
- The workflow halts execution when a signal or a timer is expected and resumes once the conditions are met.
Recovery (e.g., After a Service Restart)
- Events are read from the journal and applied to the workflow.
- All previously executed
IO
s and received signals are skipped if corresponding events are already registered. - Once all events are processed, the workflow continues execution as normal.