33import abc
44import dataclasses
55import typing
6+ import uuid
67
78from cqrs .events .event import IEvent
89from cqrs .response import IResponse
@@ -17,8 +18,6 @@ class SagaStepResult(typing.Generic[ContextT, Resp]):
1718 Result of a saga step execution.
1819
1920 Contains the response from the step's act method and metadata about the step.
20- The step_type field uses typing.Any for compatibility,
21- but the actual runtime type is Type[SagaStepHandler[ContextT, Resp]].
2221
2322 This is an internal data structure used by the saga pattern implementation.
2423
@@ -29,6 +28,8 @@ class SagaStepResult(typing.Generic[ContextT, Resp]):
2928 error_message: Error message if with_error is True
3029 error_traceback: Error traceback lines if with_error is True
3130 error_type: Type of exception if with_error is True
31+ saga_id: ID of the saga this step belongs to (set by execution layer).
32+ Enables client code to trigger compensation immediately if the saga fails.
3233
3334 Example::
3435
@@ -40,11 +41,12 @@ class SagaStepResult(typing.Generic[ContextT, Resp]):
4041 """
4142
4243 response : Resp
43- step_type : typing . Any # type: ignore[assignment] # Actual type: Type [SagaStepHandler[ContextT, Resp]]
44+ step_type : type [SagaStepHandler [ContextT , Resp ]]
4445 with_error : bool = False
4546 error_message : str | None = None
4647 error_traceback : list [str ] | None = None
4748 error_type : typing .Type [Exception ] | None = None
49+ saga_id : uuid .UUID | None = None
4850
4951
5052class SagaStepHandler (abc .ABC , typing .Generic [ContextT , Resp ]):
0 commit comments