static google::cloud::storage::Client CreateClient()

in e2e-examples/gcs/benchmark/gcscpp_runner.cc [35:76]


static google::cloud::storage::Client CreateClient(
    const Parameters& parameters) {
  auto opts = google::cloud::Options{};
  if (parameters.write_size > 0) {
    // Make a upload buffer big enough to make it done in a single rpc call if
    // chunk_size is not specified explicitly.
    std::size_t upload_buffer_size =
        (std::size_t)((parameters.chunk_size < 0) ? parameters.write_size
                                                  : parameters.chunk_size);
    opts.set<google::cloud::storage::UploadBufferSizeOption>(
        upload_buffer_size);
  }
  if (parameters.client == "gcscpp-grpc") {
    std::string target = parameters.host;
    if (target.empty()) {
      target = "storage.googleapis.com";
    }
    if (parameters.td) {
      target = "google-c2p:///" + target;
    }
    if (parameters.carg != 0) {
      opts.set<google::cloud::GrpcNumChannelsOption>(parameters.carg);
    }
    if (parameters.tx_zerocopy) {
      grpc::ChannelArguments channel_arguments;
      channel_arguments.SetInt(GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED, 1);
      opts.set<google::cloud::GrpcChannelArgumentsNativeOption>(
          channel_arguments);
    }
    return ::google::cloud::storage::MakeGrpcClient(
        opts.set<google::cloud::EndpointOption>(target));
  } else {
    if (!parameters.host.empty()) {
      opts.set<google::cloud::storage::RestEndpointOption>(parameters.host);
    }
    if (!parameters.target_api_version.empty()) {
      opts.set<google::cloud::storage::internal::TargetApiVersionOption>(
          parameters.target_api_version);
    }
    return ::google::cloud::storage::Client(std::move(opts));
  }
}