Skip to content
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

Merged
merged 9 commits into from
Aug 22, 2017
Merged

reusing socket #10

merged 9 commits into from
Aug 22, 2017

Conversation

litzenberger
Copy link
Collaborator

No description provided.

@litzenberger litzenberger self-assigned this Aug 10, 2017
Copy link
Member

@mcollina mcollina left a 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");
});
}
});
Copy link
Member

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?

Copy link
Collaborator Author

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) {
Copy link
Member

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.

Copy link
Collaborator Author

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});
Copy link
Member

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')



Copy link
Member

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.

Copy link
Collaborator Author

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.

@coveralls
Copy link

coveralls commented Aug 13, 2017

Coverage Status

Changes Unknown when pulling 185d8dc on http-agent into ** on master**.

@coveralls
Copy link

coveralls commented Aug 14, 2017

Coverage Status

Changes Unknown when pulling ff7364f on http-agent into ** on master**.

@@ -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)
Copy link
Member

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=
Copy link
Member

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.

Copy link
Collaborator Author

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})
Copy link
Member

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

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})
Copy link
Member

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.

Copy link
Collaborator Author

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.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 25aaa5a on http-agent into ** on master**.

2 similar comments
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 25aaa5a on http-agent into ** on master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 25aaa5a on http-agent into ** on master**.

@coveralls
Copy link

coveralls commented Aug 18, 2017

Coverage Status

Changes Unknown when pulling def7210 on http-agent into ** on master**.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@litzenberger litzenberger merged commit 06e14ce into master Aug 22, 2017
@litzenberger litzenberger deleted the http-agent branch August 22, 2017 03:40
@mcollina mcollina mentioned this pull request Aug 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants