minos.saga.executions.saga

Classes

SagaExecution

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
classmethod from_raw(raw, **kwargs)[source]

Build a new instance from a raw representation.

Parameters
Returns

A SagaExecution instance.

Return type

SagaExecution

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

SagaExecution

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

SagaExecution

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

SagaContext

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

async reject(*args, **kwargs)[source]

Reject the execution transactions.

Parameters
  • args – Additional positional arguments.

  • kwargs – Additional named arguments.

Returns

This method does not return anything.

Return type

None

property raw: dict[str, Any]

Compute a raw representation of the instance.

Returns

A dict instance.