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

WIP: Subscriber rate limiting #633

Merged
merged 35 commits into from Feb 26, 2023
Merged

WIP: Subscriber rate limiting #633

merged 35 commits into from Feb 26, 2023

Conversation

binwiederhier
Copy link
Owner

No description provided.

@binwiederhier
Copy link
Owner Author

@karmanyaahm I cleaned things up a little and added tests. There are still some issues, but I think this works nicely.

}
return t.rateVisitor
}

Copy link
Contributor

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.

Copy link
Owner Author

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 if len(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-commenter
Copy link

codecov-commenter commented Feb 24, 2023

Codecov Report

Base: 66.58% // Head: 66.61% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (f7f343f) compared to base (a372eb9).
Patch coverage: 75.77% of modified lines in pull request are covered.

📣 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     
Impacted Files Coverage Δ
server/errors.go 31.25% <ø> (-37.50%) ⬇️
server/log.go 78.84% <ø> (ø)
user/manager.go 60.00% <0.00%> (-0.96%) ⬇️
server/server_manager.go 65.00% <18.75%> (-4.16%) ⬇️
server/server_matrix.go 80.95% <75.00%> (-0.30%) ⬇️
server/server.go 62.13% <85.71%> (+0.87%) ⬆️
server/util.go 86.36% <88.23%> (+0.64%) ⬆️
server/topic.go 94.44% <92.00%> (-1.56%) ⬇️
server/server_middleware.go 81.81% <100.00%> (-2.40%) ⬇️
server/visitor.go 94.85% <100.00%> (+0.75%) ⬆️
... and 5 more

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@binwiederhier binwiederhier merged commit f7f343f into main Feb 26, 2023
@binwiederhier binwiederhier deleted the vrate branch August 17, 2023 20:27
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.

None yet

3 participants