Skip to content

Commit

Permalink
add support for consul admin partition query param
Browse files Browse the repository at this point in the history
  • Loading branch information
youreddy committed Oct 18, 2024
1 parent 2bb6a2a commit e20d596
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const consul = new Consul();
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.

- dc (String, optional): datacenter (defaults to local for agent)
- partition (String, optional): partition (defaults to 'default' partition)
- wan (Boolean, default: false): return WAN members instead of LAN members
- consistent (Boolean, default: false): require strong consistency
- stale (Boolean, default: false): use whatever is available, can be arbitrarily stale
Expand Down
1 change: 1 addition & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
exports.DEFAULT_OPTIONS = [
"consistent",
"dc",
"partition",
"stale",
"timeout",
"token",
Expand Down
1 change: 1 addition & 0 deletions lib/consul.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface CommonOptions {

interface DefaultOptions extends CommonOptions {
dc?: string;
partition?: string;
wan?: boolean;
consistent?: boolean;
stale?: boolean;
Expand Down
1 change: 1 addition & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ function options(req, opts, ignore) {
if (!req.query) req.query = {};

if (opts.dc && !ignore.dc) req.query.dc = opts.dc;
if (opts.partition && !ignore.partition) req.query.partition = opts.partition;
if (opts.wan && !ignore.wan) req.query.wan = "1";

if (opts.consistent && !ignore.consistent) {
Expand Down
2 changes: 2 additions & 0 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ describe("utils", function () {
should(
test({
dc: "dc1",
partition: "partition1",
wan: true,
consistent: true,
index: 10,
Expand All @@ -166,6 +167,7 @@ describe("utils", function () {
},
query: {
dc: "dc1",
partition: "partition1",
wan: "1",
consistent: "1",
index: 10,
Expand Down

0 comments on commit e20d596

Please sign in to comment.