Skip to content
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

[FEATURE] Add Saga capability #330

Open
guibranco opened this issue Feb 12, 2024 · 1 comment · May be fixed by #581
Open

[FEATURE] Add Saga capability #330

guibranco opened this issue Feb 12, 2024 · 1 comment · May be fixed by #581
Labels
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. good first issue Good for newcomers hacktoberfest Participation in the Hacktoberfest event help wanted Extra attention is needed IoC 🛠 WIP Work in progress

Comments

@guibranco
Copy link
Owner

guibranco commented Feb 12, 2024

Description

To enhance our command/event handling capabilities, we must integrate SAGA pattern support into the CommandsConsumer and EventsConsumer classes.
This will allow us to handle complex workflows involving multiple commands and events, manage long-running processes, and implement timeouts effectively.

Problem Statement

  • Current Issue: Our current setup does not support the SAGA pattern, which limits our ability to manage complex workflows and transactions across multiple events and commands. This can result in difficulties with process coordination, consistency, and timeout management.
    Impact: Without SAGA capabilities, managing long-running transactions and complex workflows becomes challenging, increasing the risk of inconsistencies and failures.

Proposed Solution

  • Integrate SAGA Pattern:
    • Implement SAGA pattern handling to manage multiple commands, events, and timeouts. This includes triggering, continuing, persisting, and completing SAGA processes.

Implementation Steps

  1. Triggering SAGA:

    • Create an abstract class, GenericSagaHandler, that inherits from the ISagaHandler interface to start a SAGA when an initial event or command is received. It should function similarly to how current events and commands trigger handlers.
    • The implementing SAGA class should inherit this class and implement the ISagaData interface.
    • For each StartedBy<T> that this class handles, it should have a Handle method implemented.
    • For each Handle<T> that this class handles, it should have a Handle method implemented.
    • For each HandleTimeout<T> that this class handles should have a Timeout method implemented.
  2. Handling Multiple Messages:

    • The SAGA should handle various types of events or commands or timeouts and maintain its state across these messages.
    • Create a SAGA data class to store and manage the SAGA state:
      public class SagaData : ISagaData
      {
          public Guid SagaId { get; set; }
          public string State { get; set; }
          public DateTime CreatedAt { get; set; }
          // Additional properties as needed
      }
  3. Correlation and State Management:

    • Ensure that SAGA data is correlated across all relevant handlers. This involves maintaining and updating the SAGA state based on incoming events or commands.
  4. Persistence:

    • Implement persistence for SAGA data, supporting SQL, NoSQL, or in-memory storage based on project needs:
      public class SagaRepository
      {
          public void Save(SagaData sagaData) { /* Implementation */ }
          public SagaData Load(Guid sagaId) { /* Implementation */ }
      }
  5. Completion:

    • Implement logic to finalize the SAGA once all required events or commands have been processed successfully. Could you ensure proper cleanup and completion handling?
  6. Timeout Feature:

    • Integrate a timeout mechanism to handle scenarios where a SAGA takes too long. Could you define timeout policies and implement recovery or failure handling for expired SAGA processes?
  7. Extend ISaga and Implement ISagaData:

    • Ensure that the SAGA implementation extends from ISaga and implements ISagaData to hold and manage SAGA details effectively.
  8. Testing:

    • Thoroughly test the SAGA integration to ensure it handles various scenarios, including normal operation, failure recovery, and timeout management. Could you verify that SAGA data is correctly managed and persisted?

Additional Notes

  • Review the SAGA pattern documentation for best practices and detailed implementation guidance.
  • Ensure the new SAGA capabilities are well-documented and integrated with existing command-handling/event-handling processes.
  • Consider performance implications and optimize the SAGA implementation to handle large-scale scenarios effectively.
@guibranco guibranco added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers events dependencies Pull requests that update a dependency file 🎲 database Database-related operations communications IoC DI hacktoberfest Participation in the Hacktoberfest event labels Feb 12, 2024
@guibranco guibranco self-assigned this Feb 12, 2024
@guibranco guibranco removed their assignment Mar 21, 2024
@gitauto-ai gitauto-ai bot added the gitauto GitAuto label to trigger the app in a issue. label Oct 23, 2024
Copy link
Contributor

gitauto-ai bot commented Oct 23, 2024

Hey, I'm a bit lost here! Not sure which file I should be fixing. Could you give me a bit more to go on? Maybe add some details to the issue or drop a comment with some extra hints? Thanks!

Have feedback or need help?
Feel free to email [email protected].

@gitauto-ai gitauto-ai bot linked a pull request Oct 23, 2024 that will close this issue
@gstraccini gstraccini bot added the 🛠 WIP Work in progress label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. good first issue Good for newcomers hacktoberfest Participation in the Hacktoberfest event help wanted Extra attention is needed IoC 🛠 WIP Work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant