@@ -199,7 +199,7 @@ the [documentation](https://github.com/vadikko2/cqrs/blob/master/examples/cor_re
199199
200200## Saga Pattern
201201
202- The package implements the Choreographic Saga pattern for managing distributed transactions across multiple services or operations.
202+ The package implements the Choreographic Saga pattern for managing distributed transactions across multiple services or operations.
203203Sagas enable eventual consistency by executing a series of steps where each step can be compensated if a subsequent step fails.
204204
205205### Key Features
@@ -236,13 +236,13 @@ class ProcessPaymentResponse(Response):
236236class ReserveInventoryStep (SagaStepHandler[OrderContext, ReserveInventoryResponse]):
237237 def __init__ (self , inventory_service ):
238238 self ._inventory_service = inventory_service
239-
239+
240240 async def act (self , context : OrderContext) -> SagaStepResult[OrderContext, ReserveInventoryResponse]:
241241 # Reserve inventory
242242 reservation_id = await self ._inventory_service.reserve_items(context.order_id, context.items)
243243 context.inventory_reservation_id = reservation_id
244244 return self ._generate_step_result(ReserveInventoryResponse(reservation_id = reservation_id))
245-
245+
246246 async def compensate (self , context : OrderContext) -> None :
247247 # Release inventory if saga fails
248248 if context.inventory_reservation_id:
@@ -251,13 +251,13 @@ class ReserveInventoryStep(SagaStepHandler[OrderContext, ReserveInventoryRespons
251251class ProcessPaymentStep (SagaStepHandler[OrderContext, ProcessPaymentResponse]):
252252 def __init__ (self , payment_service ):
253253 self ._payment_service = payment_service
254-
254+
255255 async def act (self , context : OrderContext) -> SagaStepResult[OrderContext, ProcessPaymentResponse]:
256256 # Process payment
257257 payment_id = await self ._payment_service.charge(context.order_id, context.total_amount)
258258 context.payment_id = payment_id
259259 return self ._generate_step_result(ProcessPaymentResponse(payment_id = payment_id))
260-
260+
261261 async def compensate (self , context : OrderContext) -> None :
262262 # Refund payment if saga fails
263263 if context.payment_id:
@@ -281,8 +281,8 @@ async with saga.transaction(context=context, saga_id=saga_id) as transaction:
281281 # If any step fails, compensation happens automatically
282282```
283283
284- The saga state and step history are persisted to ` SagaStorage ` . The ` SagaLog ` maintains a complete audit trail
285- of all step executions (both ` act ` and ` compensate ` operations) with timestamps and status information.
284+ The saga state and step history are persisted to ` SagaStorage ` . The ` SagaLog ` maintains a complete audit trail
285+ of all step executions (both ` act ` and ` compensate ` operations) with timestamps and status information.
286286This enables the recovery mechanism to restore saga state and ensure eventual consistency even after system failures.
287287
288288If a saga is interrupted (e.g., due to a crash), you can recover it using the recovery mechanism:
0 commit comments