lib/rpc-client/router.js
function rrRoute(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 index;
    if (!client.rrParam) {
        client.rrParam = {};
    }
    if (client.rrParam[serverType]) {
        index = client.rrParam[serverType];
    } else {
        index = 0;
    }
    utils.invokeCallback(cb, null, servers[index % servers.length]);
    if (index++ === Number.MAX_VALUE) {
        index = 0;
    }
    client.rrParam[serverType] = index;
}
function rrRoute(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 index;
    if (!client.rrParam) {
        client.rrParam = {};
    }
    if (client.rrParam[serverType]) {
        index = client.rrParam[serverType];
    } else {
        index = 0;
    }
    utils.invokeCallback(cb, null, servers[index % servers.length]);
    if (index++ === Number.MAX_VALUE) {
        index = 0;
    }
    client.rrParam[serverType] = index;
}
function rrRoute ( client , serverType , msg , cb ) { const servers = client . _station . serversMap [ serverType ] ; if ( ! servers || ! servers . length ) { utils . invokeCallback ( cb , new Error ( ` ${ serverType } ` ) ) ; return ; } let index ; if ( ! client . rrParam ) { client . rrParam = { } ; } if ( client . rrParam [ serverType ] ) { index = client . rrParam [ serverType ] ; } else { index = 0 ; } utils . invokeCallback ( cb , null , servers [ index % servers . length ] ) ; if ( index ++ === Number . MAX_VALUE ) { index = 0 ; } client . rrParam [ serverType ] = index ; }
Round-Robin 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).
Round - Robin algorithm for calculating server id .