Namespace google::cloud::storage_experimental (2.27.0)

Contains experimental features for the GCS C++ Client Library.

Classes

AsyncClient

A client for Google Cloud Storage offering asynchronous operations.

AsyncConnection

The *Connection object for AsyncClient.

AsyncReader

A handle for streaming downloads.

AsyncReaderConnection

The *Connection object for AsyncReader.

AsyncRewriter

Perform object rewrites asynchronously.

AsyncRewriterConnection

An interface for asynchronous object rewrite implementations.

AsyncToken

Serialize streams of asynchronous operations.

AsyncWriter

Perform resumable uploads asynchronously.

AsyncWriterConnection

An interface to asynchronously perform resumable uploads.

BucketName

Represent bucket names.

IdempotencyPolicy

Define the interface for the AsyncClient's idempotency policy.

ReadPayload

A partial or full response to an asynchronous download.

ResumePolicy

Controls how the client library resumes uploads and downloads.

WritePayload

An opaque representation of the data for an object payload.

Structs

BufferedUploadHwmOption

Configure the flow control algorithm for buffered uploads.

BufferedUploadLwmOption

Configure the flow control algorithm for buffered uploads.

EnableCrc32cValidationOption

If enabled, the client computes (if necessary) and validates the CRC32C checksum of an object during uploads and downloads.

EnableGrpcMetricsOption

Enable gRPC telemetry for GCS RPCs.

EnableMD5ValidationOption

If enabled, the client computes (if necessary) and validates the MD5 hash of an object during uploads and downloads.

GrpcMetricsPeriodOption

gRPC telemetry export period.

GrpcPluginOption

Configure the GCS+gRPC plugin.

HttpVersionOption

Set the HTTP version used by the client.

IdempotencyPolicyOption

An option (see google::cloud::Options) to set the idempotency policy.

ResumePolicyOption

Configure the resume policy used in a request, client, or connection.

UseCrc32cValueOption

If this option is present, the client does not compute the MD5 hash of an object during uploads or downloads.

UseMD5ValueOption

If this option is present, the client does not compute the MD5 hash of an object during uploads or downloads.

Functions

MakeBucketName(absl::string_view)

Constructs a BucketName from the given full_name.

Returns a non-OK Status if full_name is improperly formed.

Parameter
Name Description
full_name
Returns
Type Description
StatusOr< BucketName >

MakeStrictIdempotencyPolicy()

Creates an idempotency policy where only safe operations are retried.

Returns
Type Description
std::unique_ptr< IdempotencyPolicy >

MakeAlwaysRetryIdempotencyPolicy()

Creates an idempotency policy that retries all operations.

Returns
Type Description
std::unique_ptr< IdempotencyPolicy >

ReadAll(AsyncReader, AsyncToken)

Accumulate all the responses from reader.

Parameters
Name Description
reader
token
Returns
Type Description
future< StatusOr< ReadPayload > >

ReadAll(StatusOr< std::pair< AsyncReader, AsyncToken > >)

Accumulate all the responses in read or return the corresponding error.

Parameter
Name Description
read
Returns
Type Description
future< StatusOr< ReadPayload > >

ReadAll(future< StatusOr< std::pair< AsyncReader, AsyncToken > > >)

Wait until pending_read is satisfied and then accumulate all the responses, or return the corresponding error.

Example
  namespace gcs_ex = google::cloud::storage_experimental;
  auto coro =
      [](gcs_ex::AsyncClient& client, std::string bucket_name,
         std::string object_name) -> google::cloud::future<std::uint64_t> {
    // For small objects, consider `ReadAll()` which accumulates all the
    // contents in memory using background threads.
    auto payload = (co_await gcs_ex::ReadAll(client.ReadObject(
                        gcs_ex::BucketName(std::move(bucket_name)),
                        std::move(object_name))))
                       .value();
    std::uint64_t count = 0;
    for (auto const& buffer : payload.contents()) {
      count += std::count(buffer.begin(), buffer.end(), '\n');
    }
    co_return count;
  };
Parameter
Name Description
pending_read
Returns
Type Description
future< StatusOr< ReadPayload > >

LimitedErrorCountResumePolicy(int)

Returns a factory which resumes up to maximum_resumes times.

Parameter
Name Description
maximum_resumes
Returns
Type Description
ResumePolicyFactory

StopOnConsecutiveErrorsResumePolicy()

Returns a factory which resumes as long as the previous attempt connected successfully.

Returns
Type Description
ResumePolicyFactory

DefaultGrpcClient(Options)

Create a google::cloud::storage::Client object configured to use gRPC.

Example
void GrpcReadWrite(std::string const& bucket_name) {
  namespace gcs = ::google::cloud::storage;
  auto constexpr kText = R"""(Hello World!)""";

  auto client = google::cloud::storage_experimental::DefaultGrpcClient();

  auto object = client.InsertObject(bucket_name, "lorem.txt", kText);
  if (!object) throw std::move(object).status();

  auto input = client.ReadObject(bucket_name, "lorem.txt",
                                 gcs::Generation(object->generation()));
  std::string const actual(std::istreambuf_iterator<char>{input}, {});
  if (input.bad()) throw google::cloud::Status(input.status());
  std::cout << "The contents read back are:\n"
            << actual
            << "\nThe received checksums are: " << input.received_hash()
            << "\nThe computed checksums are: " << input.computed_hash()
            << "\nThe original hashes    are: crc32c=" << object->crc32c()
            << ",md5=" << object->md5_hash() << "\n";
}
Parameter
Name Description
opts

the configuration parameters for the Client.

Returns
Type Description
google::cloud::storage::Client

Type Aliases

ResumePolicyFactory

Alias Of: std::function< std::unique_ptr< ResumePolicy >()>

Creates new instances of a ResumePolicy.