Actyx / machines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

linear API for workflows

rkuhn opened this issue · comments

Inspired by conversations with Temporal we could investigate using async function* for writing machines. One idea is to await events and yield new states. Or yielding a new state (which suspends the generator until new events arrive) returns the next batch of events.

In the auction example, yielding the Auction state would resume with either a Bid or Selected event, so writing the state progression would be done using a while loop. In contrast to Rust the while condition cannot bind a new variable, so this would be less compact, but it could still make the workflow structure nicer to read than with the current Auction.react(...) API.

A completely different approach would be to offer an API for non-UI code, i.e. including also the decision-making business logic in the generator; one open question here is how to ensure that commands are only performed when the local log has been consumed in full (i.e. forcing inclusion of events coming in from other peers).