std::shared_ptr ConnectionFactory::Connect()

in src/hbase/connection/connection-factory.cc [64:87]


std::shared_ptr<HBaseService> ConnectionFactory::Connect(
    std::shared_ptr<RpcConnection> rpc_connection,
    std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>> client_bootstrap,
    const std::string &hostname, uint16_t port) {
  // connection should happen from an IO thread
  try {
    auto future = via(io_executor_.get()).then([=]() {
      VLOG(1) << "Connecting to server: " << hostname << ":" << port;
      return client_bootstrap->connect(folly::SocketAddress(hostname, port, true),
                                       std::chrono::duration_cast<milliseconds>(connect_timeout_));
    });

    // See about using shared promise for this.
    auto pipeline = future.get();

    VLOG(1) << "Connected to server: " << hostname << ":" << port;
    auto dispatcher =
        std::make_shared<ClientDispatcher>(hostname + ":" + folly::to<std::string>(port));
    dispatcher->setPipeline(pipeline);
    return dispatcher;
  } catch (const folly::AsyncSocketException &e) {
    throw ConnectionException(folly::exception_wrapper{e});
  }
}