-
Notifications
You must be signed in to change notification settings - Fork 2
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
Agents 'n' timeouts #13
Conversation
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.
Code looks good 👍
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.
Code review only. I attempted to bump okta-profile-monitor
but tests got quite upset, & i can't fall in that rabbit hole at the moment.
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.
code lookin 👌
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.
I am failing to figure out how to test effectively. How do i know which agent is being used or the state of the tcp socket at a given time?
Code looks good to me, though, & i definitely see the value in this. 👍
Yeah, I get that. I added it to a script of mine, and it cut the runtime by 40%, so that was the biggest sign for me that it was working. |
Lots of ooey-gooey deliciousness in this one.
First up: Agents. They help "manage connection persistence". In a nutshell, they can help you reuse a pool of sockets for a given host and port, so you don't need a new TCP connection for every request. Think about any application making lots of requests in a row to an upstream service.
Also included: timeouts. Sometimes your upstream service is unreliable, and just hangs. You'd like the option to end the relationship early and try again with another socket. Now you can pass the
timeout
option, and when the request times out, you canbackoff
based on errors with a code of'ECONNRESET'
. I'm sure you can think of other reasons to timeout, but here's a quick example:to review:
Agent
to a service or script of your choice:const agent = new Agent({ keepAlive: true })
agent.destroy()
when everything is done. Your OS will thank you for releasing the sockets.Fixes #12