Operation Handlers
Operation handlers perform side effects and return typed results. They do not own workflow routing.
dart
reserve.implement(
(operation, order) => reservationService.reserve(
order,
idempotencyKey: operation.context.idempotencyKey,
),
);A class may implement OperationHandler<I, O>, or an Operation may bind a concise callback through implement. Handlers belong in the product module, not in workflow code.
Rules
- Use
context.idempotencyKeyfor every external write. - Heartbeat long work; the lease is the liveness indicator.
- Classify failures as retryable or permanent.
- Do not start other workflows or respond to work from a handler. Return a result and let the workflow decide.
Retries
The runtime creates the next attempt. Manual retry through the service API creates a new attempt and keeps the idempotency key. Exhausted work appears in the dead-letter list.