From 3ba4b1b0a856b36deefe67264dd0657c17e8858b Mon Sep 17 00:00:00 2001 From: Carlos Justiniano Date: Mon, 31 Jul 2017 18:48:12 -0400 Subject: [PATCH] cache hostName and use in presence monitoring (#144) --- index.js | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 76d30f8..3ab24cf 100755 --- a/index.js +++ b/index.js @@ -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()')); } @@ -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); @@ -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, diff --git a/package.json b/package.json index 665192c..316ea5a 100644 --- a/package.json +++ b/package.json @@ -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",