Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
thread the code name through flipr
Browse files Browse the repository at this point in the history
  • Loading branch information
Raynos committed Feb 29, 2016
1 parent dd40c86 commit ed75c32
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
9 changes: 7 additions & 2 deletions circuits.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ function Circuits(options) {
this.statsd = options.statsd;
this.circuitsByServiceName = {};
this.config = options.config || {};
this.shorts = null;
this.shorts = options.shorts;
this.codeName = options.codeName;

this.stateOptions = new StateOptions(null, {
timeHeap: options.timeHeap,
Expand All @@ -111,6 +112,10 @@ function Circuits(options) {
this.egressNodes = options.egressNodes;
}

Circuits.prototype.updateCodeName = function updateCodeName(codeName) {
this.codeName = codeName;
};

Circuits.prototype.updateShorts = function updateShorts(shorts) {
this.shorts = parseShorts(shorts);
var keys = Object.keys(this.circuitsByServiceName);
Expand Down Expand Up @@ -351,7 +356,7 @@ PeriodicState.prototype.getRequestError = function getRequestError() {
return null;
}

return new ErrorFrame('Unhealthy', 'Service is not healthy');
return new ErrorFrame(this.circuit.root.codeName, 'Service is not healthy');
};

function HealthyState(options) {
Expand Down
11 changes: 11 additions & 0 deletions clients/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ function onRemoteConfigUpdate(changedKeys, forceUpdate) {
self.updateLazyHandling(hasChanged, forceUpdate);
self.updateCircuitsEnabled(hasChanged, forceUpdate);
self.updateCircuitShorts(hasChanged, forceUpdate);
self.updateCircuitCodeName(hasChanged, forceUpdate);
self.updateRateLimitingEnabled(hasChanged, forceUpdate);
self.updateTotalRpsLimit(hasChanged, forceUpdate);
self.updateExemptServices(hasChanged, forceUpdate);
Expand Down Expand Up @@ -550,6 +551,16 @@ ApplicationClients.prototype.updateCircuitShorts = function updateCircuitShorts(
}
};

ApplicationClients.prototype.updateCircuitCodeName =
function updateCircuitCodeName(hasChanged, forceUpdate) {
var self = this;
if (forceUpdate || hasChanged['circuits.codeName']) {
self.serviceProxy.updateCircuitCodeName(
self.remoteConfig.get('circuits.codeName', 'Declined')
);
}
};

ApplicationClients.prototype.updateRateLimitingEnabled = function updateRateLimitingEnabled(hasChanged, forceUpdate) {
var self = this;
if (forceUpdate || hasChanged['rateLimiting.enabled']) {
Expand Down
15 changes: 14 additions & 1 deletion service-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function ServiceDispatchHandler(options) {
'*~hyperbahn~ad': true,
'*~hyperbahn~relay-ad': true
};
self.circuitsCodeName = 'Declined';
self.circuits = null;

self.rateLimiter = new RateLimiter({
Expand Down Expand Up @@ -1502,10 +1503,22 @@ function initCircuits() {
random: self.random,
egressNodes: self.egressNodes,
config: self.circuitsConfig,
shorts: self.circuitShorts
shorts: self.circuitShorts,
codeName: self.circuitsCodeName
});
};

ServiceDispatchHandler.prototype.updateCircuitCodeName =
function updateCircuitCodeName(codeName) {
var self = this;

self.circuitsCodeName = codeName;

if (self.circuits) {
self.circuits.updateCodeName(codeName);
}
};

ServiceDispatchHandler.prototype.updateCircuitShorts =
function updateCircuitShorts(shorts) {
var self = this;
Expand Down
1 change: 1 addition & 0 deletions test/lib/relay-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ RelayNetwork.prototype.setCluster = function setCluster(cluster) {
rateLimiterEnabled: self.rateLimiterEnabled,
circuitsConfig: self.circuitsConfig
});
relayChannel.handler.updateCircuitCodeName('Unhealthy');

var hyperbahnChannel = relayChannel.makeSubChannel({
serviceName: 'hyperbahn'
Expand Down

0 comments on commit ed75c32

Please sign in to comment.