Skip to content

πŸš€ Saga Step Identity

Choose a tag to compare

@vadikko2 vadikko2 released this 02 Feb 11:00
· 13 commits to master since this release
ce4dbdf

✨ Added

  • Saga step result includes saga ID β€” Each SagaStepResult yielded from saga execution now carries a saga_id field (uuid.UUID | None). This lets client code identify which saga a step belongs to and, if desired, trigger compensation immediately when a saga fails mid-way (e.g. via a dedicated API that runs compensation for a given saga_id).

πŸ”§ Changed

  • Stricter typing for SagaStepResult.step_type β€” The step_type field is now typed as type[SagaStepHandler[ContextT, Resp]] instead of typing.Any, improving type safety and IDE support without introducing new dependencies or circular imports (both types live in the same module).

πŸ“‹ Technical details

  • SagaTransaction sets saga_id on each yielded SagaStepResult via dataclasses.replace() so that every step result has the current saga's ID when consumed from mediator.stream() or saga.transaction().
  • saga_id is optional (None by default) so that results created outside the execution layer (e.g. in step handlers via _generate_step_result()) remain valid; the execution layer fills it in when yielding to the client.

⚠️ Compatibility

  • Backward compatible β€” New field saga_id has a default of None. Existing code that does not use saga_id continues to work unchanged. The change to step_type is annotation-only; runtime behavior is unchanged.