minos.saga.definitions.saga
Classes
Saga class. |
- class Saga[source]
Bases:
object
Saga class.
The purpose of this class is to define a sequence of operations among microservices.
- __init__(*args, steps=None, committed=False, commit=None, **kwargs)[source]
- Parameters
steps (Optional[list[minos.saga.definitions.steps.abc.SagaStep]]) –
committed (bool) –
commit (None) –
- conditional_step(step=None)[source]
Add a new conditional step.
- Parameters
step (Optional[ConditionalSagaStep]) – The step to be added. If None is provided then a new one will be created.
- Returns
A
SagaStep
instance.- Return type
- local_step(step=None, **kwargs)[source]
Add a new local step.
- Parameters
step (Optional[Union[Callable[[SagaContext, ...], Union[SagaContext, None, Awaitable[Optional[SagaContext]]]], SagaOperation[Callable[[SagaContext, ...], Union[SagaContext, None, Awaitable[Optional[SagaContext]]]]], LocalSagaStep]]) – The step to be added. If None is provided then a new one will be created.
kwargs – Additional named parameters.
- Returns
A
SagaStep
instance.- Return type
- step(step=None, **kwargs)[source]
Add a new remote step step.
- Parameters
step (Optional[Union[Callable[[SagaContext, ...], Union[SagaRequest, Awaitable[SagaRequest]]], SagaOperation[Callable[[SagaContext, ...], Union[SagaRequest, Awaitable[SagaRequest]]]], RemoteSagaStep]]) – The step to be added. If None is provided then a new one will be created.
kwargs – Additional named parameters.
- Returns
A
SagaStep
instance.- Return type
- remote_step(step=None, **kwargs)[source]
Add a new remote step step.
- Parameters
step (Optional[Union[Callable[[SagaContext, ...], Union[SagaRequest, Awaitable[SagaRequest]]], SagaOperation[Callable[[SagaContext, ...], Union[SagaRequest, Awaitable[SagaRequest]]]], RemoteSagaStep]]) – The step to be added. If None is provided then a new one will be created.
kwargs – Additional named parameters.
- Returns
A
SagaStep
instance.- Return type
- property raw: dict[str, Any]
Generate a raw representation of the instance.
- Returns
A
dict
instance.