-
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
reusing socket #10
reusing socket #10
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.
The changes fo the test should not be needed. However, I would like to have a test. Maybe in the unit ones?
pino-eventhub.js
Outdated
debug("socket has been closed"); | ||
}); | ||
} | ||
}); |
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.
why are we taking track of the socket?
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 was just using it to show that the socket was being reused. I can remove that.
pino-eventhub.js
Outdated
@@ -28,7 +30,7 @@ function createSignature (uri, ttl, sapk, warn) { | |||
return encodeURIComponent(hash) | |||
} | |||
|
|||
function pinoEventHub (opts) { | |||
function pinoEventHub (opts, keepAliveAgent, sockets) { |
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 think the signature shoul stay as before.
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.
yep got it.
start.js
Outdated
@@ -23,6 +25,9 @@ function start (opts) { | |||
const sapn = opts['shared-access-policy-name'] || process.env.PINO_SHARED_ACCESS_POLICY_NAME | |||
const sapk = opts['shared-access-policy-key'] || process.env.PINO_SHARED_ACCESS_POLICY_KEY | |||
const sas = opts['sas'] || process.env.PINO_SHARED_ACCESS_SIGNATURE | |||
const agent = new https.Agent({ keepAlive: true ,maxSockets: 1}); |
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 would make the number of sockets configurable, with a default like 10.
pino-eventhub.js
Outdated
@@ -10,6 +10,8 @@ const https = require('https') | |||
const debug = require('debug')('pino-eventhub') | |||
const Parse = require('fast-json-parse') | |||
|
|||
|
|||
|
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.
these spaces are not needed. Are we running standard here? It should fail. If not, let's add 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.
We are running standard. I'll verify this.
Changes Unknown when pulling 185d8dc on http-agent into ** on master**. |
Changes Unknown when pulling ff7364f on http-agent into ** on master**. |
test/pino-eventhub.js
Outdated
@@ -39,6 +39,7 @@ lab.experiment('Pino Event Hub', () => { | |||
lab.test('returns done', (done) => { | |||
const sig = pino.createSignature(uri, se, sapk, true) | |||
expect(sig).to.exist() | |||
console.log(sig) |
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 remove this?
.travis.yml
Outdated
- PINO_SHARED_ACCESS_POLICY_NAME=sendPinoEvent | ||
- secure: NWCKKPmwiUJDzeI0tuG9EyOMZ1M8we2yDeG++Qftwk9pYjsOdT2ln6nZEYYMZbZIgMHHhoSfB/F6+ayNWn8fJU7b+WYma2lZjrNqii1szWKrAKKp4BW2Popm/fbl/7btUCrONsOQxA8x9XN8dK3dI0ocdu88eNFd7eRzJrUlOj+DgOto7bJfCnnDCqmAAohR0nD0FzYIRlxvj+w/ze4I60DU3cYdDraOEgw9VzrJx0iTm2cnDgMY3wNFiO5QTcQ6iND73gN7SnG3u/nOgUnTXnhqwX9b4LINe78sSCoKabeLj2gSw66epXQGyJL3VlELGajdBom46GwdJcBS8/iX7h82RZBlsIrNA+jFKEoW7Wehdguv0DKNHlFG+O5qkM++upEMezjTw5nX4f8CLGd4ffrz5JCen5IjBbxafTmZ7ts85tAlrOG9YunxxgySZKEh4mWONdS7jVVKFVEhDXdzfVzHNs4VQ133lrT2JBN21u3QoAlXBshiHdXnlJ5S+nes4r0qQliqKiCtTGOzxD9+hGj9bnhzi0GaUt0W4WAIOd5Y7rh3BMKaDHppIsrHEzRetT38Vf2YxvoRAbZ8Di5qX54SRVJKj2wE6TDdCDdaceWiKsabRlmVd7qWY6mQDFQ2i96JytOad0AAn1RL77PCKaaXpelBKldiXVPtJAj5wqA= | ||
- PINO_SHARED_ACCESS_POLICY_NAME=sendPinoEvent | ||
- secure: PMCGYxIRYtap+zPJRIOmBlgd4UoVNlEko0nCZFaCgsQoMBCn8FIcDPOVTG8v/di/lvYBtZgr2T+GLcfDIMazzSG2m+nh1LGbErduMollU+jfnHAYmif3vcQaJIAf15EcAXiovfp+tqiinouDyQ+3OjDtLm/NLvBeQAndSo9Ge9eQx+5jXtw17CgfOiTdBmBMqODSF3ZUadQBY5l2YPGIlWjRD5FbAc/tkETiscUCghWBsHUyWg6dw4WswuPr9gjj82a3IBzAy7mIhkeB8aJErqYIpjcclI2VXql9waAxjz+4Ea1S0aY841UlehiStFMDKVByoBbIWYA0/z5wr0feVJSgcMF/qgF975/p+WSOJFpbbyG6NIsV/Ew7llN926Lg5X8w8kkk9l6FC0MJtRsh98QuC+XRhFvt4SuOl9K7LfIXFMmknXclcmALZVzBg6U2gZOkRZFMBttSJrwR3xaU3WFDz4kxtLz3yt9pk26MXyUO2N8lvupoXjk7VNGfDXdy6BriZVPbGBjwia5+l8MIJwEVbt6LZainV/SLZNCjQmd1KRLSSsFtqXPT3ApUkEZnxZSHBQKTm2CG0x25C2Wxcf52bfHpPkyvn31bBc/i3PPs5IIpN5KiLkhnAQOTvIlPfaIzjblC/yLL4OokavUx7I8yf/vzXxI/fzC5HXQt9wE= |
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 we set them via the travis UI? It might be easier as they need to be changed often.
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'll look into that.
pino-eventhub.js
Outdated
@@ -9,6 +9,9 @@ const crypto = require('crypto') | |||
const https = require('https') | |||
const debug = require('debug')('pino-eventhub') | |||
const Parse = require('fast-json-parse') | |||
const socketCount = 10 | |||
|
|||
const agent = new https.Agent({keepAlive: true, maxSockets: socketCount}) |
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.
this should not be limited to the single module, it should be created within
pino-eventhub/pino-eventhub.js
Line 34 in ff7364f
function pinoEventHub (opts) { |
start.js
Outdated
@@ -23,6 +25,8 @@ function start (opts) { | |||
const sapn = opts['shared-access-policy-name'] || process.env.PINO_SHARED_ACCESS_POLICY_NAME | |||
const sapk = opts['shared-access-policy-key'] || process.env.PINO_SHARED_ACCESS_POLICY_KEY | |||
const sas = opts['sas'] || process.env.PINO_SHARED_ACCESS_SIGNATURE | |||
const max = opts['max'] || socketCount | |||
const agent = new https.Agent({keepAlive: true, maxSockets: max}) |
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 should not create the agent here, but in the other file.
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.
yes, been thinking about this more and need to do some refactoring. Thanks for the feedback.
Changes Unknown when pulling 25aaa5a on http-agent into ** on master**. |
2 similar comments
Changes Unknown when pulling 25aaa5a on http-agent into ** on master**. |
Changes Unknown when pulling 25aaa5a on http-agent into ** on master**. |
Changes Unknown when pulling def7210 on http-agent into ** on master**. |
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
No description provided.