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

Track processed events in Azure provider #1527

Merged
merged 13 commits into from
Mar 20, 2024

Conversation

MarcAstr0
Copy link
Collaborator

@MarcAstr0 MarcAstr0 commented Mar 15, 2024

Description

The changes in this PR aim to correct a behavior noticed in the Azure provider, where the Cosmos DB change feed would get triggered more than once for the same event, resulting in the same event being processed twice. This behavior has been seen to happen during load-balancing scenarios.

To correct this duplicate-event behavior, a new processed events container is added to Cosmos DB to store the IDs of events that the event processor has processed. The processor will query this container for the event IDs and verify the event has not been processed (i.e., it can't find its ID in this new processed-events container). If an event with the same ID is found, to avoid duplication, the event processor will ignore it and log a warning indicating the duplication.

The IDs store in the processed events container have a time-to-live (TTL) and will get cleared automatically.

Changes

  • Modifies framework-provider-azure-infrastructure package adding the new container for processed events.
  • Adds a configurable processedEventsTtl to BoosterConfig for setting the TTL of the event IDs in the processed events container (defaults to 300 seconds, i.e., 5 minutes).
  • Makes the necessary changes to the BoosterEventProcessor in the framework-core package for querying and storing the processed event IDs.
  • Modifies the adapters in the framework-provider-azure package for interacting with the processed events container.
  • For backwards compatibility, adds dummy functions to the (now deprecated) AWS and the local provider packages that will skip any verification for duplicate events since this behavior hasn't been reported in these providers.

Checks

  • Project Builds
  • Project passes tests and checks
  • Updated documentation accordingly

Copy link

what-the-diff bot commented Mar 15, 2024

PR Summary

  • Tracking of Processed Events
    Added a new JSON file to keep track of processed events in Azure. This ensures the repetition of events is avoided, enhancing performance and efficiency.

  • Update in the Core Framework
    Added new functionalities in the core framework which allow for filtering and storing of unprocessed events. These changes ensure that only new events are dispatched to event handlers.

  • Addition of Event Storage Utility
    Added new methods in the event storage service to handle storing and searching for processed events. This facilitates efficient event tracking and retrieval.

  • New Tests for Event Processing
    Incorporated a new test case to verify if already processed events are filtered before dispatch to event handlers, enhancing the accuracy of event dispatches.

  • AWS and Azure Infrastructure Update
    For both providers, added dummy methods that return an empty array representing processed events. These methods ensure compatibility across different providers.

  • Azure Infrastructure Enhancement
    By creating a container for storing processed events, the improved Azure infrastructure facilitates the tracking and retrieval of processed events.

  • Improved Event Adapters
    For both AWS and Azure, new methods were introduced for storing and fetching processed events. This results in better management of events and ensures processed events can be easily retrieved.

  • Configurations and Interface Enhancements
    Several new methods, interfaces, and properties have been added to different files. These additions provide new features such as processed events storage and search, enhancing the flexibility and functionality of the booster configuration class.

  • Minor Changes
    Small changes have been made to some files, assuring a better and more refined coding structure.

@MarcAstr0
Copy link
Collaborator Author

/integration sha=cffd25137016b4b4eae2032990dfc81c8e8fee6f

1 similar comment
@NickSeagull
Copy link
Member

/integration sha=cffd25137016b4b4eae2032990dfc81c8e8fee6f

Copy link
Contributor

⌛ Integration tests are running...

Check their status here 👈

Copy link
Contributor

❌ Oh no! Integration tests have failed

@MarcAstr0
Copy link
Collaborator Author

/integration sha=cffd25137016b4b4eae2032990dfc81c8e8fee6f

Copy link
Contributor

⌛ Integration tests are running...

Check their status here 👈

Copy link
Contributor

❌ Oh no! Integration tests have failed

@MarcAstr0 MarcAstr0 requested a review from alvaroloes March 18, 2024 22:27
@MarcAstr0
Copy link
Collaborator Author

/integration sha=79aacd308959f34dcad0106d20bc9cb3949a3f9d

Copy link
Contributor

⌛ Integration tests are running...

Check their status here 👈

Copy link
Contributor

✅ Integration tests have finished successfully!

Copy link
Contributor

@alvaroloes alvaroloes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some nitpicking comments and one a bit more important about what to return when any other error happens while storing the dispatched event

packages/framework-core/src/services/event-store.ts Outdated Show resolved Hide resolved
packages/framework-core/src/services/event-store.ts Outdated Show resolved Hide resolved
packages/framework-types/src/config.ts Outdated Show resolved Hide resolved
packages/framework-types/src/provider.ts Outdated Show resolved Hide resolved
packages/framework-types/src/provider.ts Outdated Show resolved Hide resolved
@MarcAstr0
Copy link
Collaborator Author

@alvaroloes all of your comments have been addressed in commit 8b06598 😉 👍

@MarcAstr0 MarcAstr0 requested a review from alvaroloes March 19, 2024 13:29
@MarcAstr0
Copy link
Collaborator Author

/integration sha=8b06598a412b227c4b93d4152d4ff6bba64a3c5a

Copy link
Contributor

⌛ Integration tests are running...

Check their status here 👈

Copy link
Contributor

✅ Integration tests have finished successfully!

Copy link
Contributor

@alvaroloes alvaroloes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but please take a look at the error "bubble up" comment and the login thing, so that it is easier to debug in prod.

packages/framework-core/src/services/event-store.ts Outdated Show resolved Hide resolved
@MarcAstr0 MarcAstr0 merged commit 7cf0d74 into boostercloud:main Mar 20, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants