When a member books a class we need to reserve the slot, email a confirmation and mark the booking processed. Should all of that be one workflow, or does the booking service cover it?
Workflow or transactional service for what happens after a booking?
Common question, written up by the Supero team.
1 answer
Use both, for different parts. The booking itself is a transactional service: extend booking:base_booking and change the booking's state by calling its operations through POST /api/v1/services/execute. The service's state machine decides which transitions are legal, validates the input and keeps the audit trail. Don't PUT status on the record yourself.
What follows is a workflow. Bind one to @create:<namespace>:<your booking type>, send the email from a service_call step, and end with a crud_operation that sets workflow_status on the booking so your UI can read the outcome from the record.
Our rule of thumb for when something belongs in a workflow: the trigger is a data event rather than a user action, the sequence crosses more than one service, or you'll later need to prove a step ran for a given record. Field validation belongs in the schema, not in either.
Your answer
Know the answer? Sign in to post it. It takes an email address and a 6-digit code.
Sign in to answer