minos.saga.executions.saga
Classes
Saga Execution class. |
- class SagaExecution[source]
Bases:
objectSaga Execution class.
- __init__(definition, uuid, context, status=SagaStatus.Created, steps=None, paused_step=None, already_rollback=False, user=None, *args, **kwargs)[source]
- Parameters
definition (Saga) –
uuid (UUID) –
context (SagaContext) –
status (SagaStatus) –
steps (Optional[list[minos.saga.executions.steps.abc.SagaStepExecution]]) –
paused_step (Optional[SagaStepExecution]) –
already_rollback (bool) –
- classmethod from_raw(raw, **kwargs)[source]
Build a new instance from a raw representation.
- Parameters
raw (Union[dict[str, Any], SagaExecution]) – The raw representation of the instance.
kwargs – Additional named arguments.
- Returns
A
SagaExecutioninstance.- Return type
- classmethod from_saga(definition, context=None, *args, **kwargs)[source]
Build a new instance from a
Sagaobject.- Parameters
definition (Saga) – The definition of the saga.
context (Optional[SagaContext]) – Initial saga execution context. If not provided, then a new empty context is created.
args – Additional positional arguments.
kwargs – Additional named arguments.
- Returns
A new
SagaExecutioninstance.- Return type
- classmethod from_definition(definition, context=None, uuid=None, *args, **kwargs)[source]
Build a new instance from a
Sagaobject.- Parameters
definition (Saga) – The definition of the saga.
context (Optional[SagaContext]) – Initial saga execution context. If not provided, then a new empty context is created.
uuid (Optional[UUID]) – The identifier of the execution. If
Noneis provided, then a new one will be generated.args – Additional positional arguments.
kwargs – Additional named arguments.
- Returns
A new
SagaExecutioninstance.- Return type
- async execute(response=None, *args, autocommit=True, **kwargs)[source]
Execute the
Sagadefinition.- Parameters
response (Optional[SagaResponse]) – An optional
SagaResponseto be consumed by the immediately next executed step.args – Additional positional arguments.
autocommit (bool) – If
Truethe commit process is performed automatically, otherwise must be performed manually.kwargs – Additional named arguments.
- Returns
A
SagaContextinstance.- Return type
- async rollback(*args, autoreject=True, **kwargs)[source]
Revert the executed operation with a compensatory operation.
- Parameters
args – Additional positional arguments.
autoreject (bool) – If
Truethe commit process is performed automatically, otherwise must be performed manually.kwargs – Additional named arguments.
- Returns
The updated execution context.
- Return type
None
- async commit(*args, **kwargs)[source]
Commit the execution transactions.
- Parameters
args – Additional positional arguments.
kwargs – Additional named arguments.
- Returns
This method does not return anything.
- Return type
None