v0.4.0 Release – Event-Dependent Workflows
I hope you are well and have a sunny Sunday, as we have here in Paris.
As promised a couple of weeks ago, I introduce today a significant feature: the ability to have workflows that depend on external events.
Suppose you have a payment process that requires a manager’s decision for invoices that exceed a threshold amount. To implement this:
- the payment process should be able to wait for such a decision
- a manager should be able to send her decision to the payment process.
There are multiple ways to propose this feature, but I wanted a strongly typed syntax that guarantees that a workflow would understand the objects we are sending to. To do so, I’ve found inspiration in some features of Kotlin or Go and propose today my version of Channels.
Infinitic’s channels work this way:
- You define them in the workflow interface (a workflow can have multiple channels)
- In the workflow implementation, you create channels through the
channelfunction provided with the abstract
- when you want the workflow to be able to receive an event, you apply the
receive()method to the channel. If you want the workflow to wait for an actual event, you add the
- An Infinitic client can send an event to this workflow. For that, it needs to create a stub of the targeted running workflow (from its interface and its
id):and to use it to send an event through its channel:
If you follow the recent developments of coroutines in Kotlin, and more generally, of any syntax of cross-systems communication, you are probably aware that there are use-cases not covered by this proposal, for example:
- The workflow may want to receive all events sent to the channels (not only the first one following a
receive()call) (like Kotlin’s Flow)
- The workflow may want to receive le last event sent to the channel (like Kotlin’s Stateflow)
For now, I’ve decided not to consider those use-cases, but Infinitic is extendable, and they could be added later if you express some needs.
That’s why I need your feedback, question, or reaction .