Google Cloud Pub/Sub C++ Client 2.13.0
A C++ Client Library for Google Cloud Pub/Sub
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
google::cloud::pubsub Namespace Reference

Contains all the Cloud Pub/Sub C++ client types and functions. More...

Classes

class  AckHandler
 Defines the interface to acknowledge and reject messages. More...
 
struct  BackoffPolicyOption
 The backoff policy. More...
 
class  BigQueryConfigBuilder
 A helper class to build google::pubsub::v1::BigQueryConfig protos. More...
 
class  BlockingPublisher
 Publish messages to the Cloud Pub/Sub service. More...
 
class  BlockingPublisherConnection
 A connection to the Cloud Pub/Sub service to publish events. More...
 
class  CloudStorageConfigBuilder
 A helper class to build google::pubsub::v1::CloudStorageConfig protos. More...
 
struct  CompressionAlgorithmOption
 Compression algorithm. More...
 
struct  CompressionThresholdOption
 Compression threshold. More...
 
struct  ConnectionOptionsTraits
 The Cloud Pub/Sub connection traits. More...
 
class  ExactlyOnceAckHandler
 Defines the interface to acknowledge and reject messages. More...
 
struct  FullPublisherActionOption
 The action taken by a full publisher. More...
 
struct  MaxBatchBytesOption
 The maximum size for the messages in a batch. More...
 
struct  MaxBatchMessagesOption
 The maximum number of messages in a batch. More...
 
struct  MaxConcurrencyOption
 The maximum callback concurrency. More...
 
struct  MaxDeadlineExtensionOption
 The maximum time by which the deadline for each incoming message is extended. More...
 
struct  MaxDeadlineTimeOption
 The maximum deadline for each incoming message. More...
 
struct  MaxHoldTimeOption
 The maximum hold time for the messages. More...
 
struct  MaxOutstandingBytesOption
 The maximum number of outstanding bytes per streaming pull. More...
 
struct  MaxOutstandingMessagesOption
 The maximum number of outstanding messages per streaming pull. More...
 
struct  MaxPendingBytesOption
 The maximum size for pending messages. More...
 
struct  MaxPendingMessagesOption
 The maximum number of pending messages. More...
 
class  Message
 The C++ representation for a Cloud Pub/Sub messages. More...
 
class  MessageBuilder
 Constructs Message objects. More...
 
struct  MessageOrderingOption
 Publisher message ordering. More...
 
struct  MinDeadlineExtensionOption
 The minimum time by which the deadline for each incoming message is extended. More...
 
class  Publisher
 Publish messages to the Cloud Pub/Sub service. More...
 
class  PublisherConnection
 A connection to the Cloud Pub/Sub service to publish events. More...
 
class  PublisherOptions
 Configuration options for a Publisher. More...
 
class  PullAckHandler
 Defines the interface to acknowledge and reject messages. More...
 
struct  PullResponse
 The response for a blocking pull. More...
 
class  PushConfigBuilder
 Helper class to create google::pubsub::v1::PushConfig protos. More...
 
struct  RetryPolicyOption
 The retry policy. More...
 
class  Schema
 Objects of this class identify a Cloud Pub/Sub schema. More...
 
struct  SchemaServiceBackoffPolicyOption
 Use with google::cloud::Options to configure the backoff policy. More...
 
class  SchemaServiceClient
 Service for doing schema-related operations. More...
 
class  SchemaServiceConnection
 The SchemaServiceConnection object for SchemaServiceClient. More...
 
class  SchemaServiceConnectionIdempotencyPolicy
 
struct  SchemaServiceConnectionIdempotencyPolicyOption
 Use with google::cloud::Options to configure which operations are retried. More...
 
struct  SchemaServiceRetryPolicyOption
 Use with google::cloud::Options to configure the retry policy. More...
 
struct  ShutdownPollingPeriodOption
 How often the session polls for automatic shutdowns. More...
 
class  Snapshot
 Objects of this class identify a Cloud Pub/Sub snapshot. More...
 
class  SnapshotBuilder
 Build a request to create a Cloud Pub/Sub snapshot. More...
 
class  Subscriber
 Receive messages from the Cloud Pub/Sub service. More...
 
class  SubscriberConnection
 A connection to the Cloud Pub/Sub service to receive events. More...
 
class  SubscriberOptions
 Configure how a Subscriber handles incoming messages. More...
 
class  Subscription
 Objects of this class identify a Cloud Pub/Sub subscription. More...
 
class  SubscriptionAdminClient
 Performs subscription administrative operations in Cloud Pub/Sub. More...
 
class  SubscriptionAdminConnection
 A connection to Cloud Pub/Sub for subscription-related administrative operations. More...
 
class  SubscriptionBuilder
 Create a Cloud Pub/Sub subscription configuration. More...
 
struct  SubscriptionOption
 Override the default subscription for a request. More...
 
class  Topic
 Objects of this class identify a Cloud Pub/Sub topic. More...
 
class  TopicAdminClient
 Performs topic admin operations in Cloud Pub/Sub. More...
 
class  TopicAdminConnection
 A connection to Cloud Pub/Sub for topic-related administrative operations. More...
 
class  TopicBuilder
 Builds requests to create or update a Cloud Pub/Sub topic. More...
 

Typedefs

using ApplicationCallback = std::function< void(Message, AckHandler)>
 Defines the interface for application-level callbacks. More...
 
using ExactlyOnceApplicationCallback = std::function< void(pubsub::Message, ExactlyOnceAckHandler)>
 Defines the interface for application-level callbacks with exactly-once delivery. More...
 
using BackoffPolicy = ::google::cloud::internal::BackoffPolicy
 The base class for backoff policies. More...
 
using ExponentialBackoffPolicy = google::cloud::internal::ExponentialBackoffPolicy
 A truncated exponential backoff policy with randomized periods. More...
 
using ConnectionOptions = ::google::cloud::ConnectionOptions< ConnectionOptionsTraits >
 Configure a connection for Cloud Pub/Sub services. More...
 
using PubsubMessageDataType = std::decay< decltype(std::declval< google::pubsub::v1::PubsubMessage >().data())>::type
 Defines the type for message data. More...
 
using PolicyOptionList = OptionList< RetryPolicyOption, BackoffPolicyOption >
 The list of all "policy" options. More...
 
using PublisherOptionList = OptionList< MaxHoldTimeOption, MaxBatchMessagesOption, MaxBatchBytesOption, MaxPendingMessagesOption, MaxPendingBytesOption, MessageOrderingOption, FullPublisherActionOption, CompressionThresholdOption >
 The list of options specific to publishers. More...
 
using SubscriberOptionList = OptionList< MaxDeadlineTimeOption, MaxDeadlineExtensionOption, MinDeadlineExtensionOption, MaxOutstandingMessagesOption, MaxOutstandingBytesOption, MaxConcurrencyOption, ShutdownPollingPeriodOption, SubscriptionOption >
 The list of options specific to subscribers. More...
 
using RetryPolicy = ::google::cloud::internal::TraitBasedRetryPolicy< pubsub_internal::RetryTraits >
 The base class for retry policies. More...
 
using LimitedTimeRetryPolicy = ::google::cloud::internal::LimitedTimeRetryPolicy< pubsub_internal::RetryTraits >
 A retry policy that limits based on time. More...
 
using LimitedErrorCountRetryPolicy = google::cloud::internal::LimitedErrorCountRetryPolicy< pubsub_internal::RetryTraits >
 A retry policy that limits the number of times a request can fail. More...
 
using SchemaServiceRetryPolicy = ::google::cloud::internal::TraitBasedRetryPolicy< pubsub_internal::SchemaServiceRetryTraits >
 
using SchemaServiceLimitedTimeRetryPolicy = ::google::cloud::internal::LimitedTimeRetryPolicy< pubsub_internal::SchemaServiceRetryTraits >
 
using SchemaServiceLimitedErrorCountRetryPolicy = ::google::cloud::internal::LimitedErrorCountRetryPolicy< pubsub_internal::SchemaServiceRetryTraits >
 
using SchemaServicePolicyOptionList = OptionList< SchemaServiceRetryPolicyOption, SchemaServiceBackoffPolicyOption, SchemaServiceConnectionIdempotencyPolicyOption >
 The options applicable to SchemaService. More...
 
using ListSubscriptionsRange = google::cloud::internal::PaginationRange< google::pubsub::v1::Subscription >
 An input range to stream Cloud Pub/Sub subscriptions. More...
 
using ListSnapshotsRange = google::cloud::internal::PaginationRange< google::pubsub::v1::Snapshot >
 An input range to stream Cloud Pub/Sub snapshots. More...
 
using ListTopicsRange = google::cloud::internal::PaginationRange< google::pubsub::v1::Topic >
 An input range to stream Cloud Pub/Sub topics. More...
 
using ListTopicSubscriptionsRange = google::cloud::internal::PaginationRange< std::string >
 An input range to stream the Cloud Pub/Sub subscriptions of a topic. More...
 
using ListTopicSnapshotsRange = google::cloud::internal::PaginationRange< std::string >
 An input range to stream the Cloud Pub/Sub snapshots of a topic. More...
 

Enumerations

enum class  FullPublisherAction { kIgnored , kRejects , kBlocks }
 Actions taken by a full publisher. More...
 

Functions

std::shared_ptr< BlockingPublisherConnectionMakeBlockingPublisherConnection (Options opts={})
 Creates a new BlockingPublisherConnection object to work with BlockingPublisher. More...
 
Options IAMPolicyOptions (Options opts={})
 Convenience function to initialize a google::cloud::iam::IAMPolicyConnection. More...
 
std::shared_ptr< PublisherConnectionMakePublisherConnection (Topic topic, std::initializer_list< internal::NonConstructible >)
 Creates a new PublisherConnection object to work with Publisher. More...
 
std::shared_ptr< PublisherConnectionMakePublisherConnection (Topic topic, Options opts={})
 Creates a new PublisherConnection object to work with Publisher. More...
 
std::shared_ptr< PublisherConnectionMakePublisherConnection (Topic topic, PublisherOptions options, ConnectionOptions connection_options={}, std::unique_ptr< RetryPolicy const > retry_policy={}, std::unique_ptr< BackoffPolicy const > backoff_policy={})
 Creates a new PublisherConnection object to work with Publisher. More...
 
std::shared_ptr< SchemaServiceConnectionMakeSchemaServiceConnection (Options options={})
 A factory function to construct an object of type SchemaServiceConnection. More...
 
std::unique_ptr< SchemaServiceConnectionIdempotencyPolicyMakeDefaultSchemaServiceConnectionIdempotencyPolicy ()
 
std::shared_ptr< SubscriberConnectionMakeSubscriberConnection (Subscription subscription, std::initializer_list< internal::NonConstructible >)
 Creates a new SubscriberConnection object to work with Subscriber. More...
 
std::shared_ptr< SubscriberConnectionMakeSubscriberConnection (Subscription subscription, Options opts={})
 Creates a new SubscriberConnection object to work with Subscriber. More...
 
std::shared_ptr< SubscriberConnectionMakeSubscriberConnection (Subscription subscription, SubscriberOptions options, ConnectionOptions connection_options={}, std::unique_ptr< pubsub::RetryPolicy const > retry_policy={}, std::unique_ptr< pubsub::BackoffPolicy const > backoff_policy={})
 Creates a new SubscriberConnection object to work with Subscriber. More...
 
std::shared_ptr< SubscriptionAdminConnectionMakeSubscriptionAdminConnection (std::initializer_list< internal::NonConstructible >)
 Creates a new SubscriptionAdminConnection object to work with SubscriptionAdminClient. More...
 
std::shared_ptr< SubscriptionAdminConnectionMakeSubscriptionAdminConnection (Options opts={})
 Creates a new SubscriptionAdminConnection object to work with SubscriptionAdminClient. More...
 
std::shared_ptr< SubscriptionAdminConnectionMakeSubscriptionAdminConnection (ConnectionOptions const &options, std::unique_ptr< pubsub::RetryPolicy const > retry_policy={}, std::unique_ptr< pubsub::BackoffPolicy const > backoff_policy={})
 Creates a new SubscriptionAdminConnection object to work with SubscriptionAdminClient. More...
 
std::shared_ptr< TopicAdminConnectionMakeTopicAdminConnection (std::initializer_list< internal::NonConstructible >)
 Creates a new TopicAdminConnection object to work with TopicAdminClient. More...
 
std::shared_ptr< TopicAdminConnectionMakeTopicAdminConnection (Options opts={})
 Creates a new TopicAdminConnection object to work with TopicAdminClient. More...
 
std::shared_ptr< TopicAdminConnectionMakeTopicAdminConnection (ConnectionOptions const &options, std::unique_ptr< pubsub::RetryPolicy const > retry_policy={}, std::unique_ptr< pubsub::BackoffPolicy const > backoff_policy={})
 Creates a new TopicAdminConnection object to work with TopicAdminClient. More...
 

Detailed Description

Contains all the Cloud Pub/Sub C++ client types and functions.

Typedef Documentation

◆ ApplicationCallback

using google::cloud::pubsub::ApplicationCallback = typedef std::function<void(Message, AckHandler)>

Defines the interface for application-level callbacks.

Applications provide a callable compatible with this type to receive messages. They acknowledge (or reject) messages using AckHandler. This is a move-only type to support asynchronously acknowledgments.

◆ BackoffPolicy

using google::cloud::pubsub::BackoffPolicy = typedef ::google::cloud::internal::BackoffPolicy

The base class for backoff policies.

◆ ConnectionOptions

Configure a connection for Cloud Pub/Sub services.

◆ ExactlyOnceApplicationCallback

Defines the interface for application-level callbacks with exactly-once delivery.

Applications provide a callable compatible with this type to receive messages. They acknowledge (or reject) messages using ExactlyOnceAckHandler. This is a move-only type to support asynchronous acknowledgments.

◆ ExponentialBackoffPolicy

using google::cloud::pubsub::ExponentialBackoffPolicy = typedef google::cloud::internal::ExponentialBackoffPolicy

A truncated exponential backoff policy with randomized periods.

◆ LimitedErrorCountRetryPolicy

using google::cloud::pubsub::LimitedErrorCountRetryPolicy = typedef google::cloud::internal::LimitedErrorCountRetryPolicy< pubsub_internal::RetryTraits>

A retry policy that limits the number of times a request can fail.

◆ LimitedTimeRetryPolicy

using google::cloud::pubsub::LimitedTimeRetryPolicy = typedef ::google::cloud::internal::LimitedTimeRetryPolicy< pubsub_internal::RetryTraits>

A retry policy that limits based on time.

◆ ListSnapshotsRange

using google::cloud::pubsub::ListSnapshotsRange = typedef google::cloud::internal::PaginationRange<google::pubsub::v1::Snapshot>

An input range to stream Cloud Pub/Sub snapshots.

This type models an input range of google::pubsub::v1::Snapshot objects. Applications can make a single pass through the results.

◆ ListSubscriptionsRange

using google::cloud::pubsub::ListSubscriptionsRange = typedef google::cloud::internal::PaginationRange<google::pubsub::v1::Subscription>

An input range to stream Cloud Pub/Sub subscriptions.

This type models an input range of google::pubsub::v1::Subscription objects. Applications can make a single pass through the results.

◆ ListTopicSnapshotsRange

using google::cloud::pubsub::ListTopicSnapshotsRange = typedef google::cloud::internal::PaginationRange<std::string>

An input range to stream the Cloud Pub/Sub snapshots of a topic.

This type models an input range of std::string objects. Applications can make a single pass through the results.

◆ ListTopicsRange

using google::cloud::pubsub::ListTopicsRange = typedef google::cloud::internal::PaginationRange<google::pubsub::v1::Topic>

An input range to stream Cloud Pub/Sub topics.

This type models an input range of google::pubsub::v1::Topic objects. Applications can make a single pass through the results.

◆ ListTopicSubscriptionsRange

using google::cloud::pubsub::ListTopicSubscriptionsRange = typedef google::cloud::internal::PaginationRange<std::string>

An input range to stream the Cloud Pub/Sub subscriptions of a topic.

This type models an input range of std::string objects. Applications can make a single pass through the results.

◆ PolicyOptionList

The list of all "policy" options.

◆ PublisherOptionList

The list of options specific to publishers.

◆ PubsubMessageDataType

using google::cloud::pubsub::PubsubMessageDataType = typedef std::decay< decltype(std::declval<google::pubsub::v1::PubsubMessage>().data())>::type

Defines the type for message data.

Inside Google some protobuf fields of type bytes are mapped to a different type than std::string. This is the case for message data. We use this type to automatically detect what is the representation for this field and use the correct mapping.

External users of the Cloud Pub/Sub C++ client library should treat this as a complicated typedef for std::string. We have no plans to change the type in the external version of the C++ client library for the foreseeable future. In the eventuality that we do decide to change the type, this would be a reason update the library major version number, and we would give users time to migrate.

In other words, external users of the Cloud Pub/Sub C++ client should simply write std::string where this type appears. For Google projects that must compile both inside and outside Google, this alias may be convenient.

◆ RetryPolicy

using google::cloud::pubsub::RetryPolicy = typedef ::google::cloud::internal::TraitBasedRetryPolicy< pubsub_internal::RetryTraits>

The base class for retry policies.

◆ SchemaServiceLimitedErrorCountRetryPolicy

using google::cloud::pubsub::SchemaServiceLimitedErrorCountRetryPolicy = typedef ::google::cloud::internal::LimitedErrorCountRetryPolicy< pubsub_internal::SchemaServiceRetryTraits>

◆ SchemaServiceLimitedTimeRetryPolicy

using google::cloud::pubsub::SchemaServiceLimitedTimeRetryPolicy = typedef ::google::cloud::internal::LimitedTimeRetryPolicy< pubsub_internal::SchemaServiceRetryTraits>

◆ SchemaServicePolicyOptionList

The options applicable to SchemaService.

◆ SchemaServiceRetryPolicy

using google::cloud::pubsub::SchemaServiceRetryPolicy = typedef ::google::cloud::internal::TraitBasedRetryPolicy< pubsub_internal::SchemaServiceRetryTraits>

Enumeration Type Documentation

◆ FullPublisherAction

Actions taken by a full publisher.

Enumerator
kIgnored 

Ignore full publishers, continue as usual.

kRejects 

Configure the publisher to reject new messages when full.

kBlocks 

Configure the publisher to block the caller when full.

Function Documentation

◆ MakeBlockingPublisherConnection()

std::shared_ptr< BlockingPublisherConnection > google::cloud::pubsub::MakeBlockingPublisherConnection ( Options  opts = {})

Creates a new BlockingPublisherConnection object to work with BlockingPublisher.

The BlockingPublisherConnection class is provided for applications wanting to mock the BlockingPublisher behavior in their tests. It is not intended for direct use.

Performance
Creating a new BlockingPublisherConnection is relatively expensive. This typically initiates connections to the service, and therefore these objects should be shared and reused when possible. Note that gRPC reuses existing OS resources (sockets) whenever possible, so applications may experience better performance on the second (and subsequent) calls to this function with the same Options from GrpcOptionList and CommonOptionList. However, this behavior is not guaranteed and applications should not rely on it.
See also
BlockingPublisherConnection
Parameters
optsThe options to use for this call. Expected options are any of the types in the following option lists.

◆ MakeDefaultSchemaServiceConnectionIdempotencyPolicy()

std::unique_ptr< SchemaServiceConnectionIdempotencyPolicy > google::cloud::pubsub::MakeDefaultSchemaServiceConnectionIdempotencyPolicy ( )

◆ MakePublisherConnection() [1/3]

std::shared_ptr< PublisherConnection > google::cloud::pubsub::MakePublisherConnection ( Topic  topic,
Options  opts = {} 
)

Creates a new PublisherConnection object to work with Publisher.

The PublisherConnection class is provided for applications wanting to mock the Publisher behavior in their tests. It is not intended for direct use.

Performance
Creating a new PublisherConnection is relatively expensive. This typically initiates connections to the service, and therefore these objects should be shared and reused when possible. Note that gRPC reuses existing OS resources (sockets) whenever possible, so applications may experience better performance on the second (and subsequent) calls to this function with the same Options from GrpcOptionList and CommonOptionList. However, this behavior is not guaranteed and applications should not rely on it.
See also
PublisherConnection
Parameters
topicthe Cloud Pub/Sub topic used by the returned PublisherConnection.
optsThe options to use for this call. Expected options are any of the types in the following option lists.

◆ MakePublisherConnection() [2/3]

std::shared_ptr< PublisherConnection > google::cloud::pubsub::MakePublisherConnection ( Topic  topic,
PublisherOptions  options,
ConnectionOptions  connection_options = {},
std::unique_ptr< RetryPolicy const >  retry_policy = {},
std::unique_ptr< BackoffPolicy const >  backoff_policy = {} 
)

Creates a new PublisherConnection object to work with Publisher.

The PublisherConnection class is not intended for direct use in applications, it is provided for applications wanting to mock the Publisher behavior in their tests.

Performance
Creating a new PublisherConnection is relatively expensive. This typically initiate connections to the service, and therefore these objects should be shared and reused when possible. Note that gRPC reuses existing OS resources (sockets) whenever possible, so applications may experience better performance on the second (and subsequent) calls to this function with the identical values for options. However, this behavior is not guaranteed and applications should not rely on it.
See also
PublisherConnection
Parameters
topicthe Cloud Pub/Sub topic used by the returned PublisherConnection.
optionsconfigure the batching policy and other parameters in the returned connection.
connection_options(optional) general configuration for this connection, this type is also used to configure pubsub::Subscriber.
retry_policy(optional) configure the retry loop.
backoff_policy(optional) configure the backoff period between retries.
Deprecated:
Please use the MakePublisherConnection method which accepts google::cloud::Options instead.

◆ MakePublisherConnection() [3/3]

std::shared_ptr< PublisherConnection > google::cloud::pubsub::MakePublisherConnection ( Topic  topic,
std::initializer_list< internal::NonConstructible >   
)

Creates a new PublisherConnection object to work with Publisher.

Note
This function exists solely for backwards compatibility. It prevents existing code that calls MakePublisherConnection(topic, {}) from breaking, due to ambiguity.
Deprecated:
Please use MakePublisherConnection(topic) instead.

◆ MakeSchemaServiceConnection()

std::shared_ptr< SchemaServiceConnection > google::cloud::pubsub::MakeSchemaServiceConnection ( Options  options = {})

A factory function to construct an object of type SchemaServiceConnection.

The returned connection object should not be used directly; instead it should be passed as an argument to the constructor of SchemaServiceClient.

The optional options argument may be used to configure aspects of the returned SchemaServiceConnection. Expected options are any of the types in the following option lists:

Note
Unexpected options will be ignored. To log unexpected options instead, set GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes in the environment.
Parameters
options(optional) Configure the SchemaServiceConnection created by this function.

◆ MakeSubscriberConnection() [1/3]

std::shared_ptr< SubscriberConnection > google::cloud::pubsub::MakeSubscriberConnection ( Subscription  subscription,
Options  opts = {} 
)

Creates a new SubscriberConnection object to work with Subscriber.

The SubscriberConnection class is not intended for direct use in applications, it is provided for applications wanting to mock the Subscriber behavior in their tests.

Performance
Creating a new SubscriberConnection is relatively expensive. This typically initiate connections to the service, and therefore these objects should be shared and reused when possible. Note that gRPC reuses existing OS resources (sockets) whenever possible, so applications may experience better performance on the second (and subsequent) calls to this function with the same Options from GrpcOptionList and CommonOptionList. However, this behavior is not guaranteed and applications should not rely on it.
See also
SubscriberConnection
Changing Retry Parameters Example
namespace pubsub = ::google::cloud::pubsub;
using ::google::cloud::future;
using ::google::cloud::Options;
using ::google::cloud::StatusOr;
auto sample = [](std::string project_id, std::string subscription_id) {
// By default a subscriber will retry for 60 seconds, with an initial
// backoff of 100ms, a maximum backoff of 60 seconds, and the backoff will
// grow by 30% after each attempt. This changes those defaults.
pubsub::Subscription(std::move(project_id), std::move(subscription_id)),
/*maximum_duration=*/std::chrono::minutes(1))
.clone())
.set<pubsub::BackoffPolicyOption>(
/*initial_delay=*/std::chrono::milliseconds(200),
/*maximum_delay=*/std::chrono::seconds(10),
/*scaling=*/2.0)
.clone())));
auto session = subscriber.Subscribe(
std::move(h).ack();
std::cout << "Received message " << m << "\n";
PleaseIgnoreThisSimplifiesTestingTheSamples();
});
return std::make_pair(subscriber, std::move(session));
};
Options & set(ValueTypeT< T > v)
Defines the interface to acknowledge and reject messages.
Definition: ack_handler.h:49
The C++ representation for a Cloud Pub/Sub messages.
Definition: message.h:78
Receive messages from the Cloud Pub/Sub service.
Definition: subscriber.h:91
future< Status > Subscribe(ApplicationCallback cb, Options opts={})
Creates a new session to receive messages from subscription.
Objects of this class identify a Cloud Pub/Sub subscription.
Definition: subscription.h:37
google::cloud::internal::ExponentialBackoffPolicy ExponentialBackoffPolicy
A truncated exponential backoff policy with randomized periods.
Definition: backoff_policy.h:31
std::shared_ptr< SubscriberConnection > MakeSubscriberConnection(Subscription subscription, std::initializer_list< internal::NonConstructible >)
Creates a new SubscriberConnection object to work with Subscriber.
::google::cloud::internal::LimitedTimeRetryPolicy< pubsub_internal::RetryTraits > LimitedTimeRetryPolicy
A retry policy that limits based on time.
Definition: retry_policy.h:50
The retry policy.
Definition: options.h:58
Parameters
subscriptionthe Cloud Pub/Sub subscription used by the returned connection.
optsThe options to use for this call. Expected options are any of the types in the following option lists.

◆ MakeSubscriberConnection() [2/3]

std::shared_ptr< SubscriberConnection > google::cloud::pubsub::MakeSubscriberConnection ( Subscription  subscription,
std::initializer_list< internal::NonConstructible >   
)

Creates a new SubscriberConnection object to work with Subscriber.

Note
This function exists solely for backwards compatibility. It prevents existing code, which calls MakeSubscriberConnection(subscription, {}) from breaking, due to ambiguity.
Deprecated:
Please use MakeSubscriberConnection(subscription) instead.

◆ MakeSubscriberConnection() [3/3]

std::shared_ptr< SubscriberConnection > google::cloud::pubsub::MakeSubscriberConnection ( Subscription  subscription,
SubscriberOptions  options,
ConnectionOptions  connection_options = {},
std::unique_ptr< pubsub::RetryPolicy const >  retry_policy = {},
std::unique_ptr< pubsub::BackoffPolicy const >  backoff_policy = {} 
)

Creates a new SubscriberConnection object to work with Subscriber.

The SubscriberConnection class is not intended for direct use in applications, it is provided for applications wanting to mock the Subscriber behavior in their tests.

Performance
Creating a new SubscriberConnection is relatively expensive. This typically initiates connections to the service, and therefore these objects should be shared and reused when possible. Note that gRPC reuses existing OS resources (sockets) whenever possible, so applications may experience better performance on the second (and subsequent) calls to this function with the identical values for options. However, this behavior is not guaranteed and applications should not rely on it.
See also
SubscriberConnection
Changing Retry Parameters Example
namespace pubsub = ::google::cloud::pubsub;
using ::google::cloud::future;
using ::google::cloud::Options;
using ::google::cloud::StatusOr;
auto sample = [](std::string project_id, std::string subscription_id) {
// By default a subscriber will retry for 60 seconds, with an initial
// backoff of 100ms, a maximum backoff of 60 seconds, and the backoff will
// grow by 30% after each attempt. This changes those defaults.
pubsub::Subscription(std::move(project_id), std::move(subscription_id)),
/*maximum_duration=*/std::chrono::minutes(1))
.clone())
.set<pubsub::BackoffPolicyOption>(
/*initial_delay=*/std::chrono::milliseconds(200),
/*maximum_delay=*/std::chrono::seconds(10),
/*scaling=*/2.0)
.clone())));
auto session = subscriber.Subscribe(
std::move(h).ack();
std::cout << "Received message " << m << "\n";
PleaseIgnoreThisSimplifiesTestingTheSamples();
});
return std::make_pair(subscriber, std::move(session));
};
Parameters
subscriptionthe Cloud Pub/Sub subscription used by the returned connection.
optionsconfigure the flow control and other parameters in the returned connection.
connection_options(optional) general configuration for this connection, this type is also used to configure pubsub::Publisher.
retry_policycontrol for how long (or how many times) are retryable RPCs attempted.
backoff_policycontrols the backoff behavior between retry attempts, typically some form of exponential backoff with jitter.
Deprecated:
Please use the MakeSubscriberConnection function which accepts google::cloud::Options instead.

◆ MakeSubscriptionAdminConnection() [1/3]

std::shared_ptr< SubscriptionAdminConnection > google::cloud::pubsub::MakeSubscriptionAdminConnection ( ConnectionOptions const &  options,
std::unique_ptr< pubsub::RetryPolicy const >  retry_policy = {},
std::unique_ptr< pubsub::BackoffPolicy const >  backoff_policy = {} 
)

Creates a new SubscriptionAdminConnection object to work with SubscriptionAdminClient.

The SubscriptionAdminConnection class is not intended for direct use in applications, it is provided for applications wanting to mock the SubscriptionAdminClient behavior in their tests.

Performance
Creating a new SubscriptionAdminConnection is relatively expensive. This typically initiates connections to the service, and therefore these objects should be shared and reused when possible. Note that gRPC reuses existing OS resources (sockets) whenever possible, so applications may experience better performance on the second (and subsequent) calls to this function with the identical values for options. However, this behavior is not guaranteed and applications should not rely on it.
See also
SubscriberConnection
Parameters
options(optional) configure the SubscriptionAdminConnection created by this function.
retry_policycontrol for how long (or how many times) are retryable RPCs attempted.
backoff_policycontrols the backoff behavior between retry attempts, typically some form of exponential backoff with jitter.
Deprecated:
Please use the MakeSubscriptionAdminConnection function that accepts google::cloud::Options instead.

◆ MakeSubscriptionAdminConnection() [2/3]

std::shared_ptr< SubscriptionAdminConnection > google::cloud::pubsub::MakeSubscriptionAdminConnection ( Options  opts = {})

Creates a new SubscriptionAdminConnection object to work with SubscriptionAdminClient.

The SubscriptionAdminConnection class is provided for applications wanting to mock the SubscriptionAdminClient behavior in their tests. It is not intended for direct use.

Performance
Creating a new SubscriptionAdminConnection is relatively expensive. This typically initiates connections to the service, and therefore these objects should be shared and reused when possible. Note that gRPC reuses existing OS resources (sockets) whenever possible, so applications may experience better performance on the second (and subsequent) calls to this function with the same Options from GrpcOptionList and CommonOptionList. However, this behavior is not guaranteed and applications should not rely on it.
See also
SubscriptionAdminClient
Parameters
optsThe options to use for this call. Expected options are any of the types in the following option lists.

◆ MakeSubscriptionAdminConnection() [3/3]

std::shared_ptr< SubscriptionAdminConnection > google::cloud::pubsub::MakeSubscriptionAdminConnection ( std::initializer_list< internal::NonConstructible >  )

Creates a new SubscriptionAdminConnection object to work with SubscriptionAdminClient.

Note
This function exists solely for backwards compatibility. It prevents existing code that calls MakeSubscriptionAdminConnection({}) from breaking, due to ambiguity.
Deprecated:
Please use MakeSubscriptionAdminConnection() instead.

◆ MakeTopicAdminConnection() [1/3]

std::shared_ptr< TopicAdminConnection > google::cloud::pubsub::MakeTopicAdminConnection ( ConnectionOptions const &  options,
std::unique_ptr< pubsub::RetryPolicy const >  retry_policy = {},
std::unique_ptr< pubsub::BackoffPolicy const >  backoff_policy = {} 
)

Creates a new TopicAdminConnection object to work with TopicAdminClient.

The TopicAdminConnection class is provided for applications wanting to mock the TopicAdminClient behavior in their tests. It is not intended for direct use.

Performance
Creating a new TopicAdminConnection is relatively expensive. This typically initiate connections to the service, and therefore these objects should be shared and reused when possible. Note that gRPC reuses existing OS resources (sockets) whenever possible, so applications may experience better performance on the second (and subsequent) calls to this function with the identical values for options. However, this behavior is not guaranteed and applications should not rely on it.
See also
TopicAdminClient
Parameters
options(optional) configure the TopicAdminConnection created by this function.
retry_policycontrol for how long (or how many times) are retryable RPCs attempted.
backoff_policycontrols the backoff behavior between retry attempts, typically some form of exponential backoff with jitter.
Deprecated:
Please use the MakeTopicAdminConnection function that accepts google::cloud::Options instead.

◆ MakeTopicAdminConnection() [2/3]

std::shared_ptr< TopicAdminConnection > google::cloud::pubsub::MakeTopicAdminConnection ( Options  opts = {})

Creates a new TopicAdminConnection object to work with TopicAdminClient.

The TopicAdminConnection class is provided for applications wanting to mock the TopicAdminClient behavior in their tests. It is not intended for direct use.

Performance
Creating a new TopicAdminConnection is relatively expensive. This typically initiates connections to the service, and therefore these objects should be shared and reused when possible. Note that gRPC reuses existing OS resources (sockets) whenever possible, so applications may experience better performance on the second (and subsequent) calls to this function with the same Options from GrpcOptionList and CommonOptionList. However, this behavior is not guaranteed and applications should not rely on it.
See also
TopicAdminClient
Parameters
optsThe options to use for this call. Expected options are any of the types in the following option lists.

◆ MakeTopicAdminConnection() [3/3]

std::shared_ptr< TopicAdminConnection > google::cloud::pubsub::MakeTopicAdminConnection ( std::initializer_list< internal::NonConstructible >  )

Creates a new TopicAdminConnection object to work with TopicAdminClient.

Note
This function exists solely for backwards compatibility. It prevents existing code that calls MakeTopicAdminConnection({}) from breaking, due to ambiguity.
Deprecated:
Please use MakeTopicAdminConnection() instead.