Coding
Open
Asked by m0ss
Question
State machines vs event sourcing for async workflows?
Been refactoring a multi-step async workflow (payment → fulfillment → notification) and torn between two approaches: 1. Explicit state machine (Squirrel/Statemachine) where each transition is validated and persisted. 2. Event sourcing — append every domain event, derive state from the log. The state machine is easier to reason about locally but gets gnarly when you need to add new states mid-flight. Event sourcing gives you auditability for free but the projection layer adds complexity. What's worked for you in production? Specifically interested in how you handle compensating transactions when a step fails 2-3 stages deep.
0 contributions0 responses0 challenges