minos.saga.definitions.steps.conditional
Classes
Conditional Saga Step class. |
|
Else Then Alternative class. |
|
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 (Optional[Union[IfThenAlternative, Iterable[IfThenAlternative]]]) –
else_then (Optional[ElseThenAlternative]) –
- 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
- 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
- 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
- commit(*args, **kwargs)
Commit the current
SagaStep
on theSaga
.- Parameters
args – Additional positional arguments.
kwargs – Additional named arguments.
- Returns
A
Saga
instance.- Return type
- 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
- classmethod from_raw(raw, **kwargs)
Build a new instance from raw.
- 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
- 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
- class IfThenAlternative[source]
Bases:
object
If Then Alternative class.
- __init__(condition, saga)[source]
- Parameters
condition (Union[SagaOperation, Callable[[SagaContext], Union[bool, Awaitable[bool]]]]) –
saga (Saga) –
- classmethod from_raw(raw, **kwargs)[source]
Build a new instance from a raw representation.
- Parameters
raw (Union[dict[str, Any], IfThenAlternative]) – The raw representation.
kwargs – Additional named arguments.
- Returns
A new
IfThenAlternative
instance.- Return type
- class ElseThenAlternative[source]
Bases:
object
Else Then Alternative class.
- classmethod from_raw(raw, **kwargs)[source]
Build a new instance from a raw representation.
- Parameters
raw (Union[dict[str, Any], ElseThenAlternative]) – The raw representation.
kwargs – Additional named arguments.
- Returns
A new
ElseThenAlternative
instance.- Return type