-
-
Notifications
You must be signed in to change notification settings - Fork 674
feat: Support for capping the number of origins in Agent #4365
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
Conversation
metcoder95
left a comment
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.
Thanks for contributing!
For Agent the situation is a bit more complicated.
As it manages pool/client per origin, might be better to re-shape the approach for it by limiting the number of origins if desired (defaulting to Inifinity).
If no more room for adding more origins, requests should be dropped; there's no way an space will be available unless explicitly preempted.
mcollina
left a comment
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.
Good work! It's a good start! I wonder if it would be better to maintain a counter in the Agent instead of sum it up at every request.
This approach makes sense to me, as controlling max connections would just become a downstream effect of limiting
When you say it's dropped, you mean that Agent shouldn't have a queue at all? If so, would it throw an exception like |
|
Okay, I've simplified it to be an I kept the queue in |
Exactly; if a max limit of |
|
@metcoder95 Agent now throws an error on dispatch when |
metcoder95
left a comment
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.
lgtm already, just test for types is missed and should be good to go
|
Merged @metcoder95 this is ready to merge when you approve the latest merge commit. |
Uzlopak
left a comment
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.
Add the Error suffix please.
Other than that codewise looks ok.
|
I am actually now a little bit hesitant. Should we really call it AgentMaxOriginsReachedError? Or should it be just MaxOriginsReachedError? Could this be also be used in Pools or Clients? If so, we should remove the Prefix "Agent". |
|
Dont change yet the code. Lets clarify first what the error is "doing", before you do extra work. |
I'm not sure I understand what you mean. 🤔 Can you clarify? I tend to agree with @Uzlopak that a more generic It's a quick change, so let me know if that's how we want to proceed. |
|
If you consider to use it in various places, than you can generalize it of course. Please proceed ;) |
|
@Uzlopak @metcoder95 Any update on when we can merge this? |
metcoder95
left a comment
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.
lgtm
mcollina
left a comment
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.
lgtm
Uzlopak
left a comment
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.
We changed the Error class thing with instanceof and symbols.
LGTM
|
can someone of you reapprove? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4365 +/- ##
=======================================
Coverage 93.53% 93.53%
=======================================
Files 103 103
Lines 32349 32378 +29
=======================================
+ Hits 30257 30286 +29
Misses 2092 2092 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Failures are unrelated to the PR itself |
This relates to...
Addresses #3268, but only for
Agent. Will addressBalancedPoolin a separate PR.Rationale
Exposes an optional
maxOriginsoption onAgentto enforce a maximum number of origins that can have open connections. ThrowsAgentMaxOriginsReachederror if attempting to dispatch a request to a new origin whenmaxOriginshas already been reached.Changes
Tracks unique origins in
Agentin aSetnamedkOrigins, alongside its internalkClientsmap, adding new origins during dispatch, and removing origins when the last connected client for an origin is disconnected. If dispatching the current request would exceedmaxOrigins, throwsAgentMaxOriginsReached.Features
maxOriginsadded toAgentto enforce an origin limitBug Fixes
N/A
Breaking Changes and Deprecations
N/A
Status