File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,12 +22,12 @@ from cqrs.saga.mermaid import SagaMermaid
2222from cqrs.saga.saga import Saga
2323from cqrs.saga.storage.memory import MemorySagaStorage
2424
25- # Create your saga (see Saga Pattern documentation for details )
26- saga = Saga(
27- steps = [ReserveInventoryStep, ProcessPaymentStep, ShipOrderStep],
28- container = container,
29- storage = MemorySagaStorage(),
30- )
25+ # Create your saga class (steps are defined as class attribute )
26+ class OrderSaga (Saga[OrderContext]):
27+ steps = [ReserveInventoryStep, ProcessPaymentStep, ShipOrderStep]
28+
29+ # Create saga instance
30+ saga = OrderSaga( )
3131
3232# Create Mermaid generator
3333generator = SagaMermaid(saga)
@@ -93,11 +93,14 @@ class ProcessPaymentStep(SagaStepHandler[OrderContext, ProcessPaymentResponse]):
9393class ShipOrderStep (SagaStepHandler[OrderContext, ShipOrderResponse]):
9494 # ... implementation
9595
96- saga = Saga(
97- steps = [ReserveInventoryStep, ProcessPaymentStep, ShipOrderStep],
98- container = container,
99- storage = storage,
100- )
96+ class OrderSaga (Saga[OrderContext]):
97+ steps = [
98+ ReserveInventoryStep,
99+ ProcessPaymentStep,
100+ ShipOrderStep,
101+ ]
102+
103+ saga = OrderSaga()
101104```
102105
103106### Generated Sequence Diagram
You can’t perform that action at this time.
0 commit comments