-
Notifications
You must be signed in to change notification settings - Fork 20
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
Open
gitauto-ai
wants to merge
8
commits into
main
Choose a base branch
from
gitauto/issue-#330-eb1ceaa8-eb9d-4cc6-ab62-7bf36608b527
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
GitAuto: [FEATURE] Add Saga capability #581
gitauto-ai
wants to merge
8
commits into
main
from
gitauto/issue-#330-eb1ceaa8-eb9d-4cc6-ab62-7bf36608b527
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
the
size/L
Denotes a PR that changes 100-499 lines, ignoring generated files.
label
Oct 23, 2024
Infisical secrets check: ✅ No secrets leaked! 💻 Scan logs12:12AM INF scanning for exposed secrets...
12:12AM INF 579 commits scanned.
12:12AM INF scan completed in 688ms
12:12AM INF no leaks found
|
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]) |
gstraccini
bot
added
communications
dependencies
Pull requests that update a dependency file
DI
enhancement
New feature or request
events
gitauto
GitAuto label to trigger the app in a issue.
good first issue
Good for newcomers
hacktoberfest
Participation in the Hacktoberfest event
help wanted
Extra attention is needed
IoC
🎲 database
Database-related operations
labels
Oct 23, 2024
gstraccini
bot
added
🚦 awaiting triage
Items that are awaiting triage or categorization
🤖 bot
Automated processes or integrations
labels
Oct 23, 2024
guibranco
removed
help wanted
Extra attention is needed
good first issue
Good for newcomers
labels
Oct 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🚦 awaiting triage
Items that are awaiting triage or categorization
🤖 bot
Automated processes or integrations
communications
🎲 database
Database-related operations
dependencies
Pull requests that update a dependency file
DI
enhancement
New feature or request
events
gitauto
GitAuto label to trigger the app in a issue.
IoC
size/L
Denotes a PR that changes 100-499 lines, ignoring generated files.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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