-
Notifications
You must be signed in to change notification settings - Fork 778
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
feat: add keep alive support #1226
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
/** | ||
* Dependencies | ||
*/ | ||
const Agent = require('http').Agent; | ||
const {Client} = require('@sendgrid/client'); | ||
const {classes: {Mail}} = require('@sendgrid/helpers'); | ||
|
||
|
@@ -40,6 +41,17 @@ class MailService { | |
return this; | ||
} | ||
|
||
/** | ||
* Reuse connections | ||
*/ | ||
setKeepAlive(keepAlive) { | ||
if (keepAlive === false) { | ||
return; | ||
} | ||
|
||
this.client.setDefaultRequest('agent', new Agent({ keepAlive: true })); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the key needs to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, good call out |
||
} | ||
|
||
/** | ||
* Twilio Email Auth passthrough for convenience. | ||
*/ | ||
|
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 about turning off keep alive? If this just returns, you can never "unset" it.
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.
keepAlive
is already false by default, its an opt-in feature