feat(event-bus): random-delay for 429 and 409 lock errors #1
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.
This pull request introduces a new utility function,
randomDelay, to improve handling of rate-limiting and lock-conflict scenarios across multiple event consumer implementations. The function is integrated into the Azure Service Bus, GCP Pub/Sub, and RabbitMQ consumer logic, and its maximum delay is configurable via an environment variable.Utility Enhancements:
src/event-bus/event-consumer/utils.ts: Added therandomDelayfunction, which introduces a randomized delay mechanism. The maximum delay can be configured using theEVENT_RANDOMIZED_DELAY_MAXenvironment variable. [1] [2]Integration with Event Consumers:
src/event-bus/event-consumer/azure-servicebus.ts: ImportedrandomDelayand integrated it into the Azure Service Bus consumer logic to handle rate-limiting and lock-conflict scenarios. [1] [2]src/event-bus/event-consumer/gcp-pubsub.ts: AddedrandomDelayto the GCP Pub/Sub consumer logic for similar scenarios. [1] [2]src/event-bus/event-consumer/rabbitmq.ts: IncorporatedrandomDelayinto the RabbitMQ consumer logic for handling rate-limiting and lock-conflict cases. [1] [2]