-
-
Notifications
You must be signed in to change notification settings - Fork 687
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
WIP: Subscriber rate limiting #633
Conversation
@karmanyaahm I cleaned things up a little and added tests. There are still some issues, but I think this works nicely. |
} | ||
return t.rateVisitor | ||
} | ||
|
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.
What happens if someone is continuously subscribed for longer than 12 hours (or rateVisitorExpiryDuration
)? Shouldn't the countdown only start after rateVisitor unsubscribed?
Also, I removed the expiry check in RateVisitor (ex. Billee) because it runs minutely through the manager/Stale anyway. The comparison is low cost though so it doesn't matter.
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.
Shouldn't the countdown only start after rateVisitor unsubscribed?
I see. What about this:
- The
topic.expires
stays 0 until somebody unsubscribes topic.Stale()
returns true iflen(subs) == 0 && expires has passed
So we don't tie the topic expiry to the rate visitor at all anymore. We just make sure the topic sticks around for a few hours, even after everybody disconnects.
I shortened the expiry time to 6 hours, which should be enough buffer time anyway. Realistically, the topic won't get cleaned up anyway, as long as messages are in the topic (see manager).
I implemented this in
8eae44e
Codecov ReportBase: 66.58% // Head: 66.61% // Increases project coverage by
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #633 +/- ##
==========================================
+ Coverage 66.58% 66.61% +0.02%
==========================================
Files 47 47
Lines 6420 6527 +107
==========================================
+ Hits 4275 4348 +73
- Misses 1469 1500 +31
- Partials 676 679 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Test driven development
Subscriber Rate Limiting Error Handling
No description provided.