Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cueball

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cueball - npm Package Compare versions

Comparing version 1.1.9 to 1.2.0

45

lib/agent.js

@@ -24,2 +24,3 @@ /*

const mod_utils = require('./utils');
const mod_vasync = require('vasync');

@@ -56,2 +57,3 @@ const Pool = mod_pool.ConnectionPool;

this.log = options.log;
this.cba_stopped = false;

@@ -95,2 +97,5 @@ mod_assert.number(options.spares, 'options.spares');

var self = this;
if (this.cba_stopped) {
throw (new Error('Cannot add a pool to a stopped agent'));
}
mod_assert.string(host, 'hostname');

@@ -162,5 +167,41 @@ var poolOpts = {

}
this.log.debug({ host: host }, 'CueBallAgent creating new pool');
this.pools[host] = new Pool(poolOpts);
};
CueBallAgent.prototype.stop = function (cb) {
var self = this;
if (this.cba_stopped) {
throw (new Error('Cannot stop a CueBallAgent that has ' +
'already stopped'));
}
this.cba_stopped = true;
this.log.debug('CueBallAgent stopping all pools');
mod_vasync.forEachParallel({
inputs: Object.keys(this.pools),
func: stopPool
}, function (err) {
self.log.info('CueBallAgent has stopped all pools');
if (cb) {
setImmediate(function () {
cb(err);
});
}
});
function stopPool(host, pcb) {
var pool = self.pools[host];
delete (self.pools[host]);
if (pool.isInState('stopped')) {
pcb();
} else {
pool.on('stateChanged', function (st) {
if (st === 'stopped') {
pcb();
}
});
pool.stop();
}
}
};
/*

@@ -175,2 +216,6 @@ * Sets up a duplex stream to be used for the given HTTP request.

CueBallAgent.prototype.addRequest = function (req, optionsOrHost, port) {
if (this.cba_stopped) {
throw (new Error('CueBallAgent is stopped and cannot handle ' +
'new requests'));
}
var options;

@@ -177,0 +222,0 @@ mod_assert.object(req, 'req');

2

package.json
{
"name": "cueball",
"version": "1.1.9",
"version": "1.2.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -87,2 +87,15 @@ cueball

### HttpAgent#stop([cb])
Stops the pools managed by this agent, calling `cb` (if given) once all have
stopped.
Once an Agent has been stopped, it can no longer accept any new requests, and
will throw an Error if asked to do so. Calling `stop()` more than once is
also an error and will throw.
Parameters
- `cb` -- optional Function (err)
## Pool

@@ -89,0 +102,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc