minos.saga.executions.saga
Classes
Saga Execution class. |
- class SagaExecution[source]
Bases:
object
Saga 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
SagaExecution
instance.- Return type
- classmethod from_saga(definition, context=None, *args, **kwargs)[source]
Build a new instance from a
Saga
object.- 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
SagaExecution
instance.- Return type
- classmethod from_definition(definition, context=None, uuid=None, *args, **kwargs)[source]
Build a new instance from a
Saga
object.- 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
None
is provided, then a new one will be generated.args – Additional positional arguments.
kwargs – Additional named arguments.
- Returns
A new
SagaExecution
instance.- Return type
- async execute(response=None, *args, autocommit=True, **kwargs)[source]
Execute the
Saga
definition.- Parameters
response (Optional[SagaResponse]) – An optional
SagaResponse
to be consumed by the immediately next executed step.args – Additional positional arguments.
autocommit (bool) – If
True
the commit process is performed automatically, otherwise must be performed manually.kwargs – Additional named arguments.
- Returns
A
SagaContext
instance.- 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
True
the 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