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

consul

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consul - npm Package Compare versions

Comparing version 0.30.0 to 0.31.0

48

lib/acl.js

@@ -23,2 +23,26 @@ /**

/**
* Creates one-time management token if not configured
*/
Acl.prototype.bootstrap = function(opts, callback) {
if (!callback) {
callback = opts;
opts = {};
}
opts = utils.normalizeKeys(opts);
opts = utils.defaults(opts, this.consul._defaults);
var req = {
name: 'acl.bootstrap',
path: '/acl/bootstrap',
type: 'json',
};
utils.options(req, opts);
this.consul._put(req, utils.body, callback);
};
/**
* Creates a new token with policy

@@ -195,2 +219,26 @@ */

/**
* Check ACL replication
*/
Acl.prototype.replication = function(opts, callback) {
if (!callback) {
callback = opts;
opts = {};
}
opts = utils.normalizeKeys(opts);
opts = utils.defaults(opts, this.consul._defaults);
var req = {
name: 'acl.replication',
path: '/acl/replication',
query: {},
};
utils.options(req, opts);
this.consul._get(req, utils.body, callback);
};
/**
* Module exports.

@@ -197,0 +245,0 @@ */

@@ -70,2 +70,25 @@ /**

/**
* Reload agent configuration
*/
Agent.prototype.reload = function(opts, callback) {
if (!callback) {
callback = opts;
opts = {};
}
opts = utils.normalizeKeys(opts);
opts = utils.defaults(opts, this.consul._defaults);
var req = {
name: 'agent.reload',
path: '/agent/reload',
};
utils.options(req, opts);
this.consul._put(req, utils.empty, callback);
};
/**
* Returns the local node configuration

@@ -72,0 +95,0 @@ */

2

lib/consul.js

@@ -42,3 +42,3 @@ /**

(opts.host || '127.0.0.1') + ':' +
(opts.port || '8500') + '/v1';
(opts.port || 8500) + '/v1';
}

@@ -45,0 +45,0 @@ opts.name = 'consul';

@@ -184,3 +184,3 @@ /**

this.consul._delete(req, utils.empty, callback);
this.consul._delete(req, utils.body, callback);
};

@@ -187,0 +187,0 @@

@@ -93,2 +93,8 @@ /**

if (!req.headers) req.headers = {};
// headers
if (opts.hasOwnProperty('token') && !ignore.token) req.headers['x-consul-token'] = opts.token;
// query
if (!req.query) req.query = {};

@@ -107,3 +113,2 @@

if (opts.hasOwnProperty('wait') && !ignore.wait) req.query.wait = opts.wait;
if (opts.hasOwnProperty('token') && !ignore.token) req.query.token = opts.token;
if (opts.hasOwnProperty('near') && !ignore.near) req.query.near = opts.near;

@@ -223,3 +228,3 @@ if (opts.hasOwnProperty('node-meta') && !ignore['node-meta']) {

if ((src.http || src.script || src.tcp) && src.interval) {
if ((src.http || src.args || src.script || src.tcp) && src.interval) {
if (src.http) {

@@ -231,3 +236,7 @@ dst.HTTP = src.http;

} else {
dst.Script = src.script;
if (src.args) {
dst.Args = src.args;
} else {
dst.Script = src.script;
}
if (src.hasOwnProperty('dockercontainerid')) dst.DockerContainerID = src.dockercontainerid;

@@ -234,0 +243,0 @@ if (src.hasOwnProperty('shell')) dst.Shell = src.shell;

@@ -33,5 +33,21 @@ /**

var backoffFactor = 100;
if (opts.hasOwnProperty('backofffactor') && typeof opts.backofffactor === 'number') {
backoffFactor = opts.backofffactor;
}
var backoffMax = 30 * 1000;
if (opts.hasOwnProperty('backoffmax') && typeof opts.backoffmax === 'number') {
backoffMax = opts.backoffmax;
}
var maxAttempts = -1;
if (opts.hasOwnProperty('maxattempts') && typeof opts.maxattempts === 'number') {
maxAttempts = opts.maxattempts;
}
self._context = { consul: consul };
self._options = options;
self._attempts = 0;
self._maxAttempts = maxAttempts;
self._backoffMax = backoffMax;
self._backoffFactor = backoffFactor;
self._method = opts.method;

@@ -93,3 +109,13 @@

Watch.prototype._wait = function() {
return Math.min(Math.pow(2, ++this._attempts), 256) * 100;
this._attempts += 1;
if (this._attemptsMaxed) {
return this._backoffMax;
}
var timeout = Math.pow(2, this._attempts) * this._backoffFactor;
if (timeout < this._backoffMax) {
return timeout;
} else {
this._attemptsMaxed = true;
return this._backoffMax;
}
};

@@ -109,2 +135,3 @@

if (res && res.statusCode === 400) return self.end();
if (self._maxAttempts >= 0 && self._attempts >= self._maxAttempts) return self.end();

@@ -135,2 +162,3 @@ utils.setTimeoutContext(function() { self._run(); }, self, self._wait());

self._attempts = 0;
self._attemptsMaxed = false;

@@ -137,0 +165,0 @@ var newIndex = res.headers['x-consul-index'];

{
"name": "consul",
"version": "0.30.0",
"version": "0.31.0",
"description": "Consul client",

@@ -27,3 +27,4 @@ "main": "./lib",

"test": "jshint lib test && jscs lib test && istanbul cover --report text _mocha -- --recursive --check-leaks && istanbul check-coverage --statements 100 --functions 100 --branches 100 --lines 100",
"acceptance": "ACCEPTANCE=true istanbul cover --report text _mocha -- test/acceptance --recursive --check-leaks --timeout 15000"
"acceptance": "ACCEPTANCE=true istanbul cover --report text _mocha -- test/acceptance --recursive --check-leaks --timeout 15000",
"acceptanceSetupMacOS": "sudo ifconfig lo0 alias 127.0.0.2 up && sudo ifconfig lo0 alias 127.0.0.3 up"
},

@@ -30,0 +31,0 @@ "keywords": [

@@ -15,3 +15,3 @@ # Consul [![Build Status](https://travis-ci.org/silas/node-consul.png?branch=master)](https://travis-ci.org/silas/node-consul)

* [Promise](#promise)
* [Common Options](#common-options)
* [Common Method Call Options](#common-options)
* [ACL](#acl)

@@ -41,6 +41,6 @@ * [Agent](#agent)

* host (String, default: 127.0.0.1): agent address
* port (String, default: 8500): agent HTTP(S) port
* port (Integer, default: 8500): agent HTTP(S) port
* secure (Boolean, default: false): enable HTTPS
* ca (String[], optional): array of strings or Buffers of trusted certificates in PEM format
* defaults (Object, optional): default options for method calls
* defaults (Object, optional): common method call options that will be included with every call (ex: set default `token`), these options can be override on a per call basis
* promisify (Boolean|Function, optional): convert callback methods to promises

@@ -71,5 +71,5 @@

<a name="common-options"></a>
### Common Options
### Common Method Call Options
These options will be passed along with any method call, although only certain endpoints support them. See the [HTTP API][consul-docs-api] for more information.
These options can be included with any method call, although only certain endpoints support them. See the [HTTP API][consul-docs-api] for more information.

@@ -94,2 +94,3 @@ * dc (String, optional): datacenter (defaults to local for agent)

* [bootstrap](#acl-bootstrap)
* [create](#acl-create)

@@ -101,3 +102,25 @@ * [update](#acl-update)

* [list](#acl-list)
* [replication](#acl-replication)
<a name="acl-bootstrap"></a>
### consul.acl.bootstrap(callback)
Creates one-time management token if not configured.
Usage
``` javascript
consul.acl.bootstrap(function(err, result) {
if (err) throw err;
});
```
Result
``` json
{
"ID": "adf4238a-882b-9ddc-4a9d-5b6758e4159e"
}
```
<a name="acl-create"></a>

@@ -258,2 +281,28 @@ ### consul.acl.create([options], callback)

<a name="acl-replication"></a>
### consul.acl.replication([options], callback)
Get the status of the ACL replication process in the datacenter.
Usage
``` javascript
consul.acl.replication(function(err, result) {
if (err) throw err;
});
```
Result
``` json
{
"Enabled": true,
"Running": true,
"SourceDatacenter": "dc1",
"ReplicatedIndex": 1976,
"LastSuccess": "2016-08-05T06:28:58Z",
"LastError": "2016-08-05T06:28:28Z"
}
```
<a name="agent"></a>

@@ -265,2 +314,3 @@ ### consul.agent

* [members](#agent-members)
* [reload](#agent-reload)
* [self](#agent-self)

@@ -317,2 +367,15 @@ * [maintenance](#agent-maintenance)

<a name="agent-reload"></a>
### consul.agent.reload([options], callback)
Reload agent configuration.
Usage
``` javascript
consul.agent.reload(function(err, result) {
if (err) throw err;
});
```
<a name="agent-self"></a>

@@ -514,3 +577,4 @@ ### consul.agent.self(callback)

* tcp (String): host:port to test, passes if connection is established, fails otherwise
* script (String): path to check script, requires interval
* args (String[]): path to check script, requires interval
* script (String): path to check script, requires interval (DEPRECATED)
* dockercontainerid (String, optional): Docker container ID to run script

@@ -1925,2 +1989,5 @@ * shell (String, optional): shell in which to run script (currently only supported with Docker)

* options (Object): method options
* backoffFactor (Integer, default: 100): backoff factor in milliseconds to apply between attempts (`backoffFactor * (2 ^ retry attempt)`)
* backoffMax (Integer, default: 30000): maximum backoff time in milliseconds to wait between attempts
* maxAttempts (Integer): maximum number of retry attempts to make before giving up

@@ -1927,0 +1994,0 @@ Usage

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