Skip to content

Add rate-limiter to forwarder#16

Merged
cleptric merged 6 commits into
mainfrom
rate-limiter
May 12, 2025
Merged

Add rate-limiter to forwarder#16
cleptric merged 6 commits into
mainfrom
rate-limiter

Conversation

@stayallive
Copy link
Copy Markdown
Collaborator

I have added a few TODO's, I think I know the answer but I wanted to check, I think we need to inspect and parse the full envelope content to be able to determine if we are required to rate limit (parts) of the submitted envelope.

I think currently the PHP SDK doesn't submit any envelope with more than 1 item in it but with my eye on logging this might change. If not, and they are still 1 item with many items we could get away with the current state of envelope parsing.

We could luckily re-use the SDK rate limiter class pretty easily (only the event type parsing is a little... meh).

Fixes #12

@stayallive stayallive requested a review from cleptric April 14, 2025 14:06
Comment thread src/EnvelopeForwarder.php Outdated
Comment thread src/EnvelopeForwarder.php
$envelope->rejectItems(static function (EnvelopeItem $envelopeItem) use ($rateLimiter) {
$envelopeItemType = $envelopeItem->getItemType();

// @TODO: We should make the rate limiter accept an arbitrary item type to allow for flexibility when adding new item types
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was merged

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

When released we can remove the TODO, will do in followup PR.

@stayallive stayallive marked this pull request as ready for review May 12, 2025 09:46
@cleptric cleptric merged commit 245d45b into main May 12, 2025
4 checks passed
@cleptric cleptric deleted the rate-limiter branch September 4, 2025 13:37
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.

Add rate limits

2 participants