Пример #1
0
 const transport::InetSocketAddress &nextServer() {
     const transport::InetSocketAddress &server = getServerByIndex(index++);
     if (index >= servers.size()) {
         index = 0;
     }
     return server;
 }
Пример #2
0
    const transport::InetSocketAddress &nextServer(const std::set<transport::InetSocketAddress>& failedServers) {
        for (unsigned int i = 0; i <= servers.size(); i++) {
            const transport::InetSocketAddress &server = getServerByIndex(index++);
            if (failedServers.empty() || failedServers.find(server) != failedServers.end()
                    || i > failedServers.size()) {
                if (index >= servers.size()) {
                    index = 0;
                }
            }
            return server;
        }

        throw Exception("Bad news, no server available.");
    }