minos.saga.executions.saga module¶
- class minos.saga.executions.saga.SagaExecution(definition, uuid, context, status=SagaStatus.Created, steps=None, paused_step=None, already_rollback=False, user=None, *args, **kwargs)[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]¶
- async commit(*args, **kwargs)[source]¶
Commit the execution transactions.
- Parameters
args – Additional positional arguments.
kwargs – Additional named arguments.
- Return type
None- Returns
This method does not return anything.
- async execute(response=None, *args, autocommit=True, **kwargs)[source]¶
Execute the
Sagadefinition.- Parameters
response (
typing.Optional[minos.saga.messages.SagaResponse]) – An optionalSagaResponseto be consumed by the immediately next executed step.args – Additional positional arguments.
autocommit (
bool) – IfTruethe commit process is performed automatically, otherwise must be performed manually.kwargs – Additional named arguments.
- Return type
- Returns
A ``SagaContext instance.
- classmethod from_definition(definition, context=None, uuid=None, *args, **kwargs)[source]¶
Build a new instance from a
Sagaobject.- Parameters
definition (
minos.saga.definitions.saga.Saga) – The definition of the saga.context (
typing.Optional[minos.saga.context.SagaContext]) – Initial saga execution context. If not provided, then a new empty context is created.uuid (
typing.Optional[uuid.UUID]) – The identifier of the execution. IfNoneis provided, then a new one will be generated.args – Additional positional arguments.
kwargs – Additional named arguments.
- Return type
- Returns
A new
SagaExecutioninstance.
- classmethod from_raw(raw, **kwargs)[source]¶
Build a new instance from a raw representation.
- Parameters
raw (
typing.Union[dict[str,typing.Any],minos.saga.executions.saga.SagaExecution]) – The raw representation of the instance.kwargs – Additional named arguments.
- Return type
- Returns
A
SagaExecutioninstance.
- classmethod from_saga(definition, context=None, *args, **kwargs)[source]¶
Build a new instance from a
Sagaobject.- Parameters
definition (
minos.saga.definitions.saga.Saga) – The definition of the saga.context (
typing.Optional[minos.saga.context.SagaContext]) – Initial saga execution context. If not provided, then a new empty context is created.args – Additional positional arguments.
kwargs – Additional named arguments.
- Return type
- Returns
A new
SagaExecutioninstance.
- property raw: dict[str, typing.Any]¶
Compute a raw representation of the instance.
- Return type
dict[str,typing.Any]- Returns
A
dictinstance.
- async reject(*args, **kwargs)[source]¶
Reject the execution transactions.
- Parameters
args – Additional positional arguments.
kwargs – Additional named arguments.
- Return type
None- Returns
This method does not return anything.
- async rollback(*args, autoreject=True, **kwargs)[source]¶
Revert the executed operation with a compensatory operation.
- Parameters
args – Additional positional arguments.
autoreject (
bool) – IfTruethe commit process is performed automatically, otherwise must be performed manually.kwargs – Additional named arguments.
- Return type
None- Returns
The updated execution context.