minos.saga.definitions.steps.conditional

Classes

ConditionalSagaStep

Conditional Saga Step class.

ElseThenAlternative

Else Then Alternative class.

IfThenAlternative

If Then Alternative class.

class ConditionalSagaStep[source]

Bases: SagaStep

Conditional Saga Step class.

__init__(if_then=None, else_then=None, **kwargs)[source]
Parameters
if_then_alternatives: list[minos.saga.definitions.steps.conditional.IfThenAlternative]
else_then_alternative: minos.saga.definitions.steps.conditional.ElseThenAlternative
if_then(condition, saga)[source]

Add a new IfThenAlternative based on a condition and a saga.

Parameters
  • condition (Callable[[SagaContext], Union[bool, Awaitable[bool]]]) – The condition that must be satisfied to execute the alternative.

  • saga (Saga) – The saga to be executed if the condition is satisfied.

Returns

This method returns the same instance that is called.

Return type

ConditionalSagaStep

else_then(saga)[source]

Set the ElseThenAlternative with the given saga.

Parameters

saga (Saga) – The saga to be executed if not any condition is met.

Returns

This method returns the same instance that is called.

Return type

ConditionalSagaStep

validate()[source]

Check if the step is valid.

Returns

This method does not return anything, but raises an exception if the step is not valid.

Return type

None

property raw: dict[str, Any]

Get the raw representation of the step.

Returns

A dict instance.

commit(*args, **kwargs)

Commit the current SagaStep on the Saga.

Parameters
  • args – Additional positional arguments.

  • kwargs – Additional named arguments.

Returns

A Saga instance.

Return type

Saga

conditional_step(*args, **kwargs)

Create a new conditional step in the Saga.

Parameters
  • args – Additional positional parameters.

  • kwargs – Additional named parameters.

Returns

A new SagaStep instance.

Return type

ConditionalSagaStep

classmethod from_raw(raw, **kwargs)

Build a new instance from raw.

Parameters
Returns

A SagaStep instance.

Return type

SagaStep

local_step(*args, **kwargs)

Create a new local step in the Saga.

Parameters
  • args – Additional positional parameters.

  • kwargs – Additional named parameters.

Returns

A new SagaStep instance.

Return type

LocalSagaStep

remote_step(*args, **kwargs)

Create a new remote step in the Saga.

Parameters
  • args – Additional positional parameters.

  • kwargs – Additional named parameters.

Returns

A new SagaStep instance.

Return type

RemoteSagaStep

step(*args, **kwargs)

Create a new step in the Saga.

Parameters
  • args – Additional positional parameters.

  • kwargs – Additional named parameters.

Returns

A new SagaStep instance.

Return type

SagaStep

class IfThenAlternative[source]

Bases: object

If Then Alternative class.

__init__(condition, saga)[source]
Parameters
classmethod from_raw(raw, **kwargs)[source]

Build a new instance from a raw representation.

Parameters
Returns

A new IfThenAlternative instance.

Return type

IfThenAlternative

validate()[source]

Check if the alternative is valid.

Returns

This method does not return anything, but raises an exception if the alternative is not valid.

Return type

None

property raw: dict[str, Any]

Get the raw representation of the alternative.

Returns

A dict value.

class ElseThenAlternative[source]

Bases: object

Else Then Alternative class.

__init__(saga)[source]
Parameters

saga (Saga) –

classmethod from_raw(raw, **kwargs)[source]

Build a new instance from a raw representation.

Parameters
Returns

A new ElseThenAlternative instance.

Return type

ElseThenAlternative

validate()[source]

Check if the alternative is valid.

Returns

This method does not return anything, but raises an exception if the alternative is not valid.

Return type

None

property raw: dict[str, Any]

Get the raw representation of the alternative.

Returns

A dict value.