This repository was archived by the owner on Sep 25, 2020. It is now read-only.

Description
When testing Ringpop in a small cluster, I have been testing how ringpop handles node failures. When a node goes down, and a request is handleOrProxy()'d, there is a period of approximately 5 seconds where ringpop continues to forward requests to the dead node. Whilst this is expected, it throws a rather ugly error response: tchannel socket error (ECONNREFUSED from connect): connect ECONNREFUSED 10.2.0.17:9880. Is there any way that an extra argument could be added to the handleOrProxy() method that would be called when such an error occurs so that we can send a formatted response that our application can read? eg. handleOrProxy(req, res, errCallback) where errCallback is something like the example below:
function errCallback (err, req, res) {
switch (err) {
case 'ECONNREFUSED':
res.end(JSON.stringify({status: 'failed', error: 'connection_refused', message: 'Could not connect to the correct server.', retry_in: 5}));
break;
case 'ETIMEDOUT':
res.end(JSON.stringify({status: 'failed', error: 'connection_timeout', message: 'The connection timed out.', retry_in: 20}));
break;
//etc.
}
}