Skip to content

Commit

Permalink
cache hostName and use in presence monitoring (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjus authored Jul 31, 2017
1 parent 48a0404 commit 3ba4b1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Hydra extends EventEmitter {
this.presenceTimerInteval = null;
this.healthTimerInterval = null;
this.initialized = false;
this.hostName = os.hostname();
this.ready = () => Promise.reject(new Error('You must call hydra.init() before invoking hydra.ready()'));
}

Expand Down Expand Up @@ -663,7 +664,8 @@ class Hydra extends EventEmitter {
updatedOn: this._getTimeStamp(),
processID: process.pid,
ip: this.config.serviceIP,
port: this.config.servicePort
port: this.config.servicePort,
hostName: this.hostName
});
if (entry) {
this.redisdb.setex(`${redisPreKey}:${this.serviceName}:${this.instanceID}:presence`, KEY_EXPIRATION_TTL, this.instanceID);
Expand Down Expand Up @@ -713,7 +715,7 @@ class Hydra extends EventEmitter {
return {
serviceName: this.serviceName,
instanceID: this.instanceID,
hostName: os.hostname(),
hostName: this.hostName,
sampledOn: this._getTimeStamp(),
processID: process.pid,
architecture: process.arch,
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": "hydra",
"version": "1.4.10",
"version": "1.4.11",
"license": "MIT",
"author": "Carlos Justiniano",
"contributors": "https://github.com/flywheelsports/hydra/graphs/contributors",
Expand Down

0 comments on commit 3ba4b1b

Please sign in to comment.