# Saga Orchestration Roadmap ## Completed (Phase 1) - [x] `Svrnty.CQRS.Sagas.Abstractions` - Core interfaces and contracts - [x] `Svrnty.CQRS.Sagas` - Orchestration engine with fluent builder API - [x] `Svrnty.CQRS.Sagas.RabbitMQ` - RabbitMQ message transport --- ## Phase 1d: Testing & Sample ### Unit Tests - [ ] `SagaBuilder` step configuration tests - [ ] `SagaOrchestrator` execution flow tests - [ ] `SagaOrchestrator` compensation flow tests - [ ] `InMemorySagaStateStore` persistence tests - [ ] `RabbitMqSagaMessageBus` serialization tests ### Integration Tests - [ ] End-to-end saga execution with RabbitMQ - [ ] Multi-step saga with compensation scenario - [ ] Concurrent saga execution tests - [ ] Connection recovery tests ### Sample Implementation - [ ] `OrderProcessingSaga` example in WarehouseManagement - ReserveInventory step - ProcessPayment step - CreateShipment step - Full compensation flow --- ## Phase 2: Persistence ### Svrnty.CQRS.Sagas.EntityFramework - [ ] `EfCoreSagaStateStore` implementation - [ ] `SagaState` entity configuration - [ ] Migration support - [ ] PostgreSQL/SQL Server compatibility - [ ] Optimistic concurrency handling ### Configuration ```csharp cqrs.AddSagas() .UseEntityFramework(); ``` --- ## Phase 3: Reliability ### Saga Timeout Service - [ ] `SagaTimeoutHostedService` - background service for stalled sagas - [ ] Configurable timeout per saga type - [ ] Automatic compensation trigger on timeout - [ ] Dead letter handling for failed compensations ### Retry Policies - [ ] Exponential backoff support - [ ] Circuit breaker integration - [ ] Polly integration option ### Idempotency - [ ] Message deduplication - [ ] Idempotent step execution - [ ] Inbox/Outbox pattern support --- ## Phase 4: Observability ### OpenTelemetry Integration - [ ] Distributed tracing for saga execution - [ ] Span per saga step - [ ] Correlation ID propagation - [ ] Metrics (saga duration, success/failure rates) ### Saga Dashboard (Optional) - [ ] Web UI for saga monitoring - [ ] Real-time saga status - [ ] Manual compensation trigger - [ ] Saga history and audit log --- ## Phase 5: Flutter Integration ### gRPC Streaming for Saga Status - [ ] `ISagaStatusStream` service - [ ] Real-time saga progress updates - [ ] Step completion notifications - [ ] Error/compensation notifications ### Flutter Client - [ ] Dart client for saga status streaming - [ ] Saga progress widget components --- ## Phase 6: Alternative Transports ### Svrnty.CQRS.Sagas.AzureServiceBus - [ ] Azure Service Bus message transport - [ ] Topic/Subscription topology - [ ] Dead letter queue handling ### Svrnty.CQRS.Sagas.Kafka - [ ] Kafka message transport - [ ] Consumer group management - [ ] Partition key strategies --- ## Future Considerations - **Event Sourcing**: Saga state as event stream - **Saga Versioning**: Handle saga definition changes gracefully - **Saga Composition**: Nested/child sagas - **Saga Scheduling**: Delayed saga start - **Multi-tenancy**: Tenant-aware saga execution