lib/rpc-client/router.js
function chRoute(client, serverType, msg, cb) {
    const servers = client._station.serversMap[serverType];
    if (!servers || !servers.length) {
        utils.invokeCallback(cb, new Error(`rpc servers not exist with serverType: ${serverType}`));
        return;
    }
    let con;
    if (!client.chParam) {
        client.chParam = {};
    }
    if (client.chParam[serverType]) {
        con = client.chParam[serverType].consistentHash;
    } else {
        client.opts.station = client._station;
        con = new ConsistentHash(servers, client.opts);
    }
    const hashFieldIndex = client.opts.hashFieldIndex;
    const field = msg.args[hashFieldIndex] || JSON.stringify(msg);
    utils.invokeCallback(cb, null, con.getNode(field));
    client.chParam[serverType] = { consistentHash: con };
}
function chRoute(client, serverType, msg, cb) {
    const servers = client._station.serversMap[serverType];
    if (!servers || !servers.length) {
        utils.invokeCallback(cb, new Error(`rpc servers not exist with serverType: ${serverType}`));
        return;
    }
    let con;
    if (!client.chParam) {
        client.chParam = {};
    }
    if (client.chParam[serverType]) {
        con = client.chParam[serverType].consistentHash;
    } else {
        client.opts.station = client._station;
        con = new ConsistentHash(servers, client.opts);
    }
    const hashFieldIndex = client.opts.hashFieldIndex;
    const field = msg.args[hashFieldIndex] || JSON.stringify(msg);
    utils.invokeCallback(cb, null, con.getNode(field));
    client.chParam[serverType] = { consistentHash: con };
}
function chRoute ( client , serverType , msg , cb ) { const servers = client . _station . serversMap [ serverType ] ; if ( ! servers || ! servers . length ) { utils . invokeCallback ( cb , new Error ( ` ${ serverType } ` ) ) ; return ; } let con ; if ( ! client . chParam ) { client . chParam = { } ; } if ( client . chParam [ serverType ] ) { con = client . chParam [ serverType ] . consistentHash ; } else { client . opts . station = client . _station ; con = new ConsistentHash ( servers , client . opts ) ; } const hashFieldIndex = client . opts . hashFieldIndex ; const field = msg . args [ hashFieldIndex ] || JSON . stringify ( msg ) ; utils . invokeCallback ( cb , null , con . getNode ( field ) ) ; client . chParam [ serverType ] = { consistentHash : con } ; }
Consistent-Hash algorithm for calculating server id.

@param client {Object} rpc client.
@param serverType {String} rpc target serverType.
@param msg {Object} rpc message.
@param cb {Function} cb(err, serverId).
Consistent - Hash algorithm for calculating server id .