Skip to content

Commit

Permalink
An /admin/gossip/status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jwolski committed Sep 30, 2015
1 parent 387f81d commit 77ebf04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/swim/gossip.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ Gossip.prototype.computeProtocolRate = function computeProtocolRate() {
return Math.max(observed, this.minProtocolPeriod);
};

Gossip.prototype.getStatus = function getStatus() {
return this.isStopped ? Gossip.Status.Stopped : Gossip.Status.Started;
};

Gossip.prototype.run = function run() {
var self = this;

Expand Down Expand Up @@ -135,4 +139,9 @@ Gossip.Defaults = {
minProtocolPeriod: 200
};

Gossip.Status = {
Started: 'started',
Stopped: 'stopped'
};

module.exports = Gossip;
12 changes: 12 additions & 0 deletions server/admin/gossip.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ function createGossipTickHandler(ringpop) {
};
}

function createGossipStatusHandler(ringpop) {
return function handleGossipStatus(arg1, arg2, hostInfo, callback) {
callback(null, null, JSON.stringify({
status: ringpop.gossip.getStatus()
}));
};
}

module.exports = {
gossipStart: {
endpoint: '/admin/gossip/start',
Expand All @@ -60,5 +68,9 @@ module.exports = {
gossipTick: {
endpoint: '/admin/gossip/tick',
handler: createGossipTickHandler
},
gossipStatus: {
endpoint: '/admin/gossip/status',
handler: createGossipStatusHandler
}
};

0 comments on commit 77ebf04

Please sign in to comment.