Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make heartbeat liveness configurable #72

Merged
merged 2 commits into from
Aug 19, 2018
Merged
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
11 changes: 5 additions & 6 deletions lib/Broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ var putils = require('./utils');

var BaseController = require('./BrokerController');

var HEARTBEAT_LIVENESS = 3;

function Broker(endpoint, conf) {
this.services = {};
this.workers = new Map();
this.rmap = new Map();

this.conf = {
heartbeat: 2500,
heartbeatLiveness: 3,
dmode: 'load',
name: 'B' + uuid.v4(),
intch: 'tcp://127.0.0.1:55550'
Expand Down Expand Up @@ -244,7 +243,7 @@ Broker.prototype.onClient = function(msg) {
} else if (type === 'worker') {
var worker = this.workers.get(msg[4]);
if (worker) {
worker.liveness = HEARTBEAT_LIVENESS;
worker.liveness = this.conf.heartbeatLiveness;
}
}
} else {
Expand Down Expand Up @@ -285,7 +284,7 @@ Broker.prototype.onWorker = function(msg) {
return;
}

worker.liveness = HEARTBEAT_LIVENESS;
worker.liveness = this.conf.heartbeatLiveness;

if (type == MDP.W_REPLY || type == MDP.W_REPLY_PARTIAL || type == MDP.W_REPLY_REJECT) {
var rid = msg[5];
Expand Down Expand Up @@ -416,7 +415,7 @@ Broker.prototype.workerRequire = function(workerId) {

var worker = {
workerId: workerId,
liveness: HEARTBEAT_LIVENESS,
liveness: this.conf.heartbeatLiveness,
rids: new Map(),
opts: {
concurrency: 100
Expand Down Expand Up @@ -516,7 +515,7 @@ Broker.prototype.workersCheck = function() {
return;
}

if (worker.liveness < HEARTBEAT_LIVENESS) {
if (worker.liveness < self.conf.heartbeatLiveness) {
self.send([workerId, MDP.WORKER, MDP.W_HEARTBEAT]);
}
});
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "pigato",
"version": "0.0.46",
"version": "0.0.47",
"private": false,
"description": "An high-performance Node.js microservices framework based on ZeroMQ",
"description": "A high-performance Node.js microservices framework based on ZeroMQ",
"author": "prdn <[email protected]> (http://ardoino.com/)",
"keywords": [
"pigato",
Expand Down