-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GitAuto: [FEATURE] Add Saga capability #581
base: main
Are you sure you want to change the base?
GitAuto: [FEATURE] Add Saga capability #581
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sonarcsharp (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
❌ Build CrispyWaffle 8.2.220 failed (commit d1aac282a0 by @gitauto-ai[bot]) |
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
❌ Build CrispyWaffle 9.1.275 failed (commit f3ca44bc5e by @guibranco) |
❌ Build CrispyWaffle 9.1.285 failed (commit c6e1045a9d by @gstraccini[bot]) |
❌ Build CrispyWaffle 9.1.299 failed (commit 19c9165cc4 by @gstraccini[bot]) |
❌ Build CrispyWaffle 9.1.304 failed (commit da874807f7 by @gstraccini[bot]) |
Infisical secrets check: ✅ No secrets leaked! 💻 Scan logs12:20AM INF scanning for exposed secrets...
12:20AM INF 650 commits scanned.
12:20AM INF scan completed in 768ms
12:20AM INF no leaks found
|
Resolves #330
What is the feature
Implement SAGA pattern support in the
CommandsConsumer
andEventsConsumer
classes to handle complex workflows involving multiple commands and events. This enhancement will enable us to manage long-running processes, coordinate processes across multiple events and commands, and implement timeouts effectively.Why we need the feature
Our current system lacks support for the SAGA pattern, limiting our ability to manage complex workflows and transactions that span multiple events and commands. This limitation leads to challenges in process coordination, maintaining consistency, and managing timeouts. By integrating SAGA capabilities, we can handle long-running transactions and complex workflows more effectively, reducing the risk of inconsistencies and failures, and improving the overall reliability of our system.
How to implement and why
To integrate the SAGA pattern, we will follow these steps:
Create a Generic Saga Handler:
GenericSagaHandler
that inherits from theISagaHandler
interface. This class will serve as the base for SAGA implementations, handling the initiation of a SAGA when an initial event or command is received, similar to how current events and commands trigger handlers.GenericSagaHandler
and implement theISagaData
interface to manage SAGA-specific data and state.Implement Handling Methods:
StartedBy<T>
message type the SAGA handles, implement a correspondingHandle
method to process the initiation of the SAGA.Handle<T>
message type, implement aHandle
method to process intermediate messages that influence the SAGA's state.HandleTimeout<T>
, implement aTimeout
method to manage timeout scenarios within the SAGA lifecycle.Create a Saga Data Class:
Define a SAGA data class to store and manage the SAGA's state across multiple messages. This class will implement the
ISagaData
interface.Example:
This data class ensures that SAGA state is maintained consistently throughout the process.
Manage Correlation and State:
SagaId
.Implement Persistence:
Develop a persistence mechanism for SAGA data to allow the state to be saved and retrieved across the application's lifetime.
The persistence layer can support SQL, NoSQL, or in-memory storage, depending on project requirements.
Example:
Persisting SAGA data ensures resilience and continuity, especially in distributed systems or in case of failures.
Implement Completion Logic:
Integrate Timeout Mechanism:
HandleTimeout<T>
methods to manage expired SAGA processes, including rollback or compensating actions if necessary.Extend ISaga Interface:
ISaga
interface and utilize theISagaData
implementations for consistent integration with existing infrastructure.Testing:
By following these steps, we can effectively integrate the SAGA pattern into our system, providing enhanced capabilities for managing complex workflows and improving overall system reliability.
About backward compatibility
The introduction of SAGA capabilities is designed to be backward compatible:
GenericSagaHandler
,SagaData
,SagaRepository
) and interfaces (ISagaHandler
,ISagaData
) are additions that do not modify existing classes or interfaces.This approach ensures that current implementations remain stable while providing the option to leverage the SAGA pattern for new or updated workflows as needed.
Test these changes locally