-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
http: subclass of Agent can override the initialization #11577
Conversation
f46f355
to
0e21c18
Compare
Just move "free" listener into "init()" method. |
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.
The changes to use this
instead of self
, let
/const
instead of var
, etc. don't look related to making Agent
subclassable, nor are they justified from a performance standpoint. Besides the unrelated changes, the factoring-out of init()
also looks ad-hoc to the specific usage of DestroyAgent
, though I'll defer to the judgement of @nodejs/http on this.
0e21c18
to
639c54f
Compare
@TimothyGu revert all replacement. |
https://github.com/request/tunnel-agent/blob/master/index.js#L47 Now TunnelingAgent can inherits from function TunnelingAgent extends http.Agent {
constructor(options = {}) {
super(options);
this.proxyOptions = this.options.proxy || {}
this.maxSockets = this.options.maxSockets || http.Agent.defaultMaxSockets
}
init() {
this.on('free', function onFree(socket, host, port) {
// override the free socket listen
});
}
// others methods
addRequest() {}
} |
ping @nodejs/http |
@lpinca I don't think so, #11567 relaxed the constraint of extended agents, this PR makes the initialization part of the agents customizable via the This needs a rebase before anyone familiar with this part of the codebase can give a review...@fengmk2 |
639c54f
to
7d8575b
Compare
@joyeecheung :) I fixed the conflicts and push again. Anyone can review now! |
Make userland's Agent inherit from http.Agent more easily.
7d8575b
to
a3b1e98
Compare
PTAL @nodejs/collaborators @nodejs/http |
oy! completely missed this one, sorry @fengmk2 |
This likely needs a doc update. Code looks fine on first read through, needs a CI |
@jasnell The ci is still running for a long time. |
the ci completed, the results just are not posting appropriately back to Github. |
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.
Can you please explain why you need sidestep the internal 'free'
event handler? That part is critical for the logic of http.Agent
. What is your use case? Maybe we are missing another event or method.
I am -1 with this change.
Ping @fengmk2 |
@fengmk2 do you still want to pursue this? |
I am closing this due to long inactivity. @fengmk2 if you would like to pursue this, please reopen. |
Make userland's Agent inherit from http.Agent more easily.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)