redis-failsafe-client

0.0.3 • Public • Published

redis-failsafe-client

A redis client for redis clusters, which recovers in case of cluster failover or rehashing.

Install

npm install redis-failsafe-client

Basic usage

var redis = require('redis-failsafe-client');
 
var client = new RedisCluster({[
    {host: 'localhost', port: 7001},
    {host: 'localhost', port: 7002},
    {host: 'localhost', port: 7003},
    {host: 'localhost', port: 7004}
]});
 
function test() {
    client.set('foo', 'bar', function (err, reply){
        console.log(err ? err : reply);
    });
    client.get('foo', function (err, reply){
        console.log(err ? err : reply);
    });
}
 
client.on('ready', test);

RedisCluster constructor parameters expect a list of initial endpoints, which is used only to meet with cluster. It will uses the first host it can connect to, to bootstrap the cluster, the initial endpoints will no longer be used during the lifetime of the client. It is not tested by the bootstrap, whether the hosts in the parameter array belong to the same cluster. All redis command

Short term improvements

  • Error handling:
    • implementing ASK asking in case of migration between cluster nodes
    • implementing MOVED handling by refreshing the cluster information
    • CLUSTERDOWN is sometimes reported by only a specific server node, which has a broken migration on importing side (i.e. the node has started an importing on slot(s), but the owner node has went through a failover), It can be recovered, by this client, but I think it will just report it, and leave to the administrator to heal the migration.
  • Fixes:
    • commands, which are not slot affine, gets no connection yet. After the fix they will get a connection in round robin manner, from the opened cluster node connections.
    • making command queue throttling configurable

Package Sidebar

Install

npm i redis-failsafe-client

Weekly Downloads

0

Version

0.0.3

License

MIT

Last publish

Collaborators

  • axelbodo