Skip to content

Commit

Permalink
fallback to address if service address is empty (#1)
Browse files Browse the repository at this point in the history
* When using external services, we may have a node Address without a ServiceAddress. In that instance, we should fall back to the Address to avoid returning an empty string.
  • Loading branch information
samicoman authored and bobthemighty committed Dec 19, 2017
1 parent ac8fa13 commit 2a4aa13
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function _Service (name, opts) {
var prev = target[key];
if (res.statusCode == 200 && data.length) {
var item = data[Math.floor(Math.random()*data.length)]
Object.assign(target[key], new _ServiceValue(item.ServiceAddress, item.ServicePort));
Object.assign(target[key], new _ServiceValue(item.ServiceAddress || item.Address, item.ServicePort));
builderOpts.emitter.emit('change', varname, item, prev);
} else {
builderOpts.log.warn('No data returned from consul for service '+_service);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "12factorial",
"version": "0.6.0",
"version": "0.6.1",
"repository": {
"type": "git",
"url": "https://github.com/bobthemighty/12factorial"
Expand Down

0 comments on commit 2a4aa13

Please sign in to comment.