Complete the code to define the first step in a saga transaction.
def saga_step_1(): # Start transaction [1]
The first step in a saga transaction is to begin the transaction to ensure all steps are tracked.
Complete the code to define the compensation action in a saga step.
def compensate_step(): # Undo previous action [1]
Compensation in saga means executing a specific action to undo the previous step.
Fix the error in the saga coordinator logic to handle step failure.
def saga_coordinator(): try: execute_step_1() execute_step_2() except Exception: [1] # Handle failure
When a step fails, the saga coordinator must execute compensation to undo previous steps.
Fill both blanks to correctly define a saga step with its compensation.
def saga_step(): try: [1] # Perform action except Exception: [2] # Perform compensation
The saga step performs an action and if it fails, it executes compensation to undo.
Fill all three blanks to define a saga coordinator managing steps and compensation.
def saga_coordinator(): [1] # Start saga try: [2] # Execute saga steps except Exception: [3] # Execute compensation
The coordinator starts the saga, executes all steps, and compensates on failure.
