Saga State
Description
Represents the current state of a saga instance, used by the orchestrator to track progress and make decisions.
Definition Schema
The definition for a saga_state
component expects the following structure:
{
"$defs": {
"SagaStateFieldInputDTO": {
"description": "Defines a single field within the SagaState DTO.",
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"type_str": {
"title": "Type Str",
"type": "string"
},
"default_value_str": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Default Value Str"
},
"is_optional": {
"default": false,
"title": "Is Optional",
"type": "boolean"
}
},
"required": [
"name",
"type_str"
],
"title": "SagaStateFieldInputDTO",
"type": "object"
}
},
"description": "DTO for defining an in-memory Saga State Pydantic model.",
"example": {
"custom_payload_fields": [
{
"default_value_str": "None",
"is_optional": true,
"name": "customer_email",
"type_str": "Optional[str]"
},
{
"name": "order_total",
"type_str": "Decimal"
}
],
"name": "OrderProcessingSagaState"
},
"properties": {
"name": {
"description": "Name of the Saga State class (e.g., 'OrderProcessingSagaState')",
"title": "Name",
"type": "string"
},
"base_fields": {
"items": {
"$ref": "#/$defs/SagaStateFieldInputDTO"
},
"title": "Base Fields",
"type": "array"
},
"custom_payload_fields": {
"description": "Custom fields to be included in the 'payload' dictionary or as top-level fields.",
"items": {
"$ref": "#/$defs/SagaStateFieldInputDTO"
},
"title": "Custom Payload Fields",
"type": "array"
}
},
"required": [
"name",
"base_fields"
],
"title": "SagaStateInputDTO",
"type": "object"
}
Naming and Location Conventions
Class: PascalCase, typically ends with 'SagaState'. File: ${saga_state_name}.py
(based on ${saga_state_name}
). Location: app/domain/${bounded_ctx}/sagas
. (Requires context: ['bounded_ctx'])
Example Definition
{
"name": "OrderProcessingSagaState",
"custom_payload_fields": [
{
"name": "customer_email",
"type_str": "Optional[str]",
"default_value_str": "None",
"is_optional": true
},
{
"name": "order_total",
"type_str": "Decimal"
}
]
}