Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Support blocking queries to /health #3

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Options
Usage

``` javascript
consul.agent.members(function(err, result) {
consul.agent.members(function(err, result, http_response) {
if (err) throw err;
});
```
Expand Down Expand Up @@ -103,7 +103,7 @@ Returns the agent node configuration.
Usage

``` javascript
consul.agent.self(function(err, result) {
consul.agent.self(function(err, result, http_response) {
if (err) throw err;
});
```
Expand Down Expand Up @@ -198,7 +198,7 @@ Options
Usage

``` javascript
consul.agent.join('127.0.0.2', function(err) {
consul.agent.join('127.0.0.2', function(err, http_response) {
if (err) throw err;
});
```
Expand All @@ -215,7 +215,7 @@ Options
Usage

``` javascript
consul.agent.forceLeave('node2', function(err) {
consul.agent.forceLeave('node2', function(err, http_response) {
if (err) throw err;
});
```
Expand Down Expand Up @@ -448,7 +448,7 @@ Lists known datacenters.
Usage

``` javascript
consul.catalog.datacenters(function(err, result) {
consul.catalog.datacenters(function(err, result, http_response) {
if (err) throw err;
});
```
Expand Down Expand Up @@ -633,7 +633,7 @@ Options
Usage

``` javascript
consul.health.node('node1', function(err, result) {
consul.health.node('node1', function(err, result, http_response) {
if (err) throw err;
});
```
Expand Down Expand Up @@ -678,7 +678,7 @@ Options
Usage

``` javascript
consul.health.checks('example', function(err, result) {
consul.health.checks('example', function(err, result, http_response) {
if (err) throw err;
});
```
Expand Down Expand Up @@ -715,7 +715,7 @@ Options
Usage

``` javascript
consul.health.service('example', function(err, result) {
consul.health.service('example', function(err, result, http_response) {
if (err) throw err;
});
```
Expand Down Expand Up @@ -774,7 +774,7 @@ Options
Usage

``` javascript
consul.health.state('unknown', function(err, result) {
consul.health.state('unknown', function(err, result, http_response) {
if (err) throw err;
});
```
Expand Down
20 changes: 8 additions & 12 deletions lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ Agent.prototype.members = function(opts, callback) {
if (opts.wan) req.query.wan = '1';

this.consul._get('/agent/members', req, function(err, res) {
if (err) return callback(err);
if (err) return callback(err, null, res);

callback(null, res.body);
callback(null, res.body, res);
});
};

Expand All @@ -73,9 +73,9 @@ Agent.prototype.self = function(callback) {
this.consul._log(['debug', 'agent', 'self']);

this.consul._get('/agent/self', function(err, res) {
if (err) return callback(err);
if (err) return callback(err, null, res);

callback(null, res.body);
callback(null, res.body, res);
});
};

Expand All @@ -101,10 +101,8 @@ Agent.prototype.join = function(opts, callback) {

if (opts.wan) req.query.wan = '1';

this.consul._get('/agent/join/{address}', req, function(err) {
if (err) return callback(err);

callback();
this.consul._get('/agent/join/{address}', req, function(err, res) {
callback(err, res);
});
};

Expand All @@ -128,10 +126,8 @@ Agent.prototype.forceLeave = function(opts, callback) {
path: { node: opts.node },
};

this.consul._get('/agent/force-leave/{node}', req, function(err) {
if (err) return callback(err);

callback();
this.consul._get('/agent/force-leave/{node}', req, function(err, res) {
callback(err, res);
});
};

Expand Down
4 changes: 2 additions & 2 deletions lib/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ Catalog.prototype.datacenters = function(callback) {
this.consul._log(['debug', 'catalog', 'datacenters']);

this.consul._get('/catalog/datacenters', function(err, res) {
if (err) return callback(err);
if (err) return callback(err, null, res);

callback(null, res.body);
callback(null, res.body, res);
});
};

Expand Down
16 changes: 8 additions & 8 deletions lib/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ Health.prototype.node = function(opts, callback) {
if (opts.dc) req.query.dc = opts.dc;

this.consul._get('/health/node/{node}', req, function(err, res) {
if (err) return callback(err);
if (err) return callback(err, null, res);

callback(null, res.body);
callback(null, res.body, res);
});
};

Expand All @@ -68,9 +68,9 @@ Health.prototype.checks = function(opts, callback) {
if (opts.dc) req.query.dc = opts.dc;

this.consul._get('/health/checks/{service}', req, function(err, res) {
if (err) return callback(err);
if (err) return callback(err, null, res);

callback(null, res.body);
callback(null, res.body, res);
});
};

Expand All @@ -97,9 +97,9 @@ Health.prototype.service = function(opts, callback) {
if (opts.passing) req.query.passing = 'true';

this.consul._get('/health/service/{service}', req, function(err, res) {
if (err) return callback(err);
if (err) return callback(err, null, res);

callback(null, res.body);
callback(null, res.body, res);
});
};

Expand Down Expand Up @@ -128,9 +128,9 @@ Health.prototype.state = function(opts, callback) {
if (opts.dc) req.query.dc = opts.dc;

this.consul._get('/health/state/{state}', req, function(err, res) {
if (err) return callback(err);
if (err) return callback(err, null, res);

callback(null, res.body);
callback(null, res.body, res);
});
};

Expand Down