Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. Promise<redis::ConnectionPtr> RedisStorage::_connect(const std::string& host, int port) {
  2.     return redis::LocalConnection::establish(loop(), host, port)
  3.         .thenDo<redis::ConnectionPtr>([host, port](redis::LocalConnectionPtr result) {
  4.              return result->info().thenDo<redis::ConnectionPtr>([result](
  5.                  redis::LocalConnection::Properties info) {
  6.  
  7.                  if(info["cluster_enabled"] == "1")
  8.                      return redis::ClusterConnection::establish(result)
  9.                          .thenDo<redis::MultiClusterConnectionPtr>([](
  10.                               redis::ClusterConnectionPtr connection) {
  11.                               return redis::MultiClusterConnection::establish(connection);
  12.  
  13.                                                                    })
  14.                          .then<redis::ConnectionPtr>([](redis::MultiClusterConnectionPtr connection)
  15. {
  16.                          return      std::dynamic_pointer_cast<redis::Connection>(connection);
  17.                              });
  18.  
  19.                  return Promise<redis::ConnectionPtr>::success(result);
  20.              });
  21.          });
  22.          }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement