Google Cloud Pub/Sub C++ Client  1.34.1
A C++ Client Library for Google Cloud Pub/Sub
Classes | Typedefs | Enumerations | Functions
google::cloud::pubsub Namespace Reference

Contains all the Cloud Pubsub C++ client types and functions. More...

Classes

class  AckHandler
 Defines the interface to acknowledge and reject messages. More...
 
struct  ConnectionOptionsTraits
 The Cloud Pub/Sub connection traits. More...
 
class  Message
 The C++ representation for a Cloud Pub/Sub messages. More...
 
class  MessageBuilder
 Constructs Message objects. More...
 
struct  RetryPolicyOption
 The retry policy. More...
 
struct  BackoffPolicyOption
 The backoff policy. More...
 
struct  MaxHoldTimeOption
 The maximum hold time for the messages. More...
 
struct  MaxBatchMessagesOption
 The maximum number of messages in a batch. More...
 
struct  MaxBatchBytesOption
 The maximum size for the messages in a batch. More...
 
struct  MaxPendingMessagesOption
 The maximum number of pending messages. More...
 
struct  MaxPendingBytesOption
 The maximum size for pending messages. More...
 
struct  MessageOrderingOption
 Publisher message ordering. More...
 
struct  FullPublisherActionOption
 The action taken by a full publisher. More...
 
struct  MaxDeadlineTimeOption
 The maximum deadline for each incoming message. More...
 
struct  MaxDeadlineExtensionOption
 The maximum time by which the deadline for each incoming message is extended. More...
 
struct  MaxOutstandingMessagesOption
 The maximum number of outstanding messages per streaming pull. More...
 
struct  MaxOutstandingBytesOption
 The maximum number of outstanding bytes per streaming pull. More...
 
struct  MaxConcurrencyOption
 The maximum callback concurrency. More...
 
struct  ShutdownPollingPeriodOption
 How often the session polls for automatic shutdowns. 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  Schema
 Objects of this class identify a Cloud Pub/Sub schema. More...
 
class  SchemaAdminClient
 Performs schema admin operations in Cloud Pub/Sub. More...
 
class  SchemaAdminConnection
 A connection to Cloud Pub/Sub for schema-related administrative operations. 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  PushConfigBuilder
 Helper class to create google::pubsub::v1::PushConfig protos. More...
 
class  SubscriptionBuilder
 Create a Cloud Pub/Sub subscription configuration. 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...
 
class  MockSchemaAdminConnection
 A googlemock-based mock for pubsub::SchemaAdminConnection. More...
 

Typedefs

using ApplicationCallback = std::function< void(Message, AckHandler)>
 Defines the interface for application-level callbacks. 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 >
 The list of options specific to publishers. More...
 
using SubscriberOptionList = OptionList< MaxDeadlineTimeOption, MaxDeadlineExtensionOption, MaxOutstandingMessagesOption, MaxOutstandingBytesOption, MaxConcurrencyOption, ShutdownPollingPeriodOption >
 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 ListSchemasRange = google::cloud::internal::PaginationRange< google::pubsub::v1::Schema >
 An input range to stream Cloud Pub/Sub schemas. 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< PublisherConnectionMakePublisherConnection (Topic topic, std::initializer_list< pubsub_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< SchemaAdminConnectionMakeSchemaAdminConnection (std::initializer_list< pubsub_internal::NonConstructible >)
 Creates a new SchemaAdminConnection object to work with SchemaAdminClient. More...
 
std::shared_ptr< SchemaAdminConnectionMakeSchemaAdminConnection (Options opts={})
 Creates a new SchemaAdminConnection object to work with SchemaAdminClient. More...
 
std::shared_ptr< SchemaAdminConnectionMakeSchemaAdminConnection (pubsub::ConnectionOptions const &options, std::unique_ptr< pubsub::RetryPolicy const > retry_policy={}, std::unique_ptr< pubsub::BackoffPolicy const > backoff_policy={})
 Creates a new SchemaAdminConnection object to work with SchemaAdminClient. More...
 
std::shared_ptr< SubscriberConnectionMakeSubscriberConnection (Subscription subscription, std::initializer_list< pubsub_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< pubsub_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< pubsub_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 Pubsub 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.

Definition at line 35 of file application_callback.h.

◆ BackoffPolicy

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

The base class for backoff policies.

Definition at line 27 of file backoff_policy.h.

◆ ConnectionOptions

Configure a connection for Cloud Pub/Sub services.

Definition at line 36 of file connection_options.h.

◆ ExponentialBackoffPolicy

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

A truncated exponential backoff policy with randomized periods.

Definition at line 30 of file backoff_policy.h.

◆ 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.

Definition at line 54 of file retry_policy.h.

◆ LimitedTimeRetryPolicy

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

A retry policy that limits based on time.

Definition at line 49 of file retry_policy.h.

◆ ListSchemasRange

using google::cloud::pubsub::ListSchemasRange = typedef google::cloud::internal::PaginationRange<google::pubsub::v1::Schema>

An input range to stream Cloud Pub/Sub schemas.

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

Definition at line 44 of file schema_admin_connection.h.

◆ 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.

Definition at line 59 of file subscription_admin_connection.h.

◆ 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.

Definition at line 47 of file subscription_admin_connection.h.

◆ 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.

Definition at line 70 of file topic_admin_connection.h.

◆ 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.

Definition at line 46 of file topic_admin_connection.h.

◆ 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.

Definition at line 58 of file topic_admin_connection.h.

◆ PolicyOptionList

The list of all "policy" options.

Definition at line 63 of file options.h.

◆ PublisherOptionList

The list of options specific to publishers.

Definition at line 173 of file options.h.

◆ 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 Pubsub 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 Pubsub 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.

Definition at line 68 of file message.h.

◆ RetryPolicy

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

The base class for retry policies.

Definition at line 45 of file retry_policy.h.

◆ SubscriberOptionList

The list of options specific to subscribers.

Definition at line 282 of file options.h.

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.

Definition at line 159 of file options.h.

Function Documentation

◆ 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 same ConnectionOptions parameters. 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< pubsub_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.

◆ MakeSchemaAdminConnection() [1/3]

std::shared_ptr<SchemaAdminConnection> google::cloud::pubsub::MakeSchemaAdminConnection ( Options  opts = {})

Creates a new SchemaAdminConnection object to work with SchemaAdminClient.

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

Performance
Creating a new SchemaAdminConnection 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
SchemaAdminClient
Parameters
optsThe options to use for this call. Expected options are any of the types in the following option lists.

◆ MakeSchemaAdminConnection() [2/3]

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

Creates a new SchemaAdminConnection object to work with SchemaAdminClient.

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

Performance
Creating a new SchemaAdminConnection 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 ConnectionOptions parameters. However, this behavior is not guaranteed and applications should not rely on it.
See also
SchemaAdminClient
Parameters
options(optional) configure the PublisherConnection 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 MakeSchemaAdminConnection function that accepts google::cloud::Options instead.

◆ MakeSchemaAdminConnection() [3/3]

std::shared_ptr<SchemaAdminConnection> google::cloud::pubsub::MakeSchemaAdminConnection ( std::initializer_list< pubsub_internal::NonConstructible >  )

Creates a new SchemaAdminConnection object to work with SchemaAdminClient.

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

◆ 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.
auto subscriber = pubsub::Subscriber(pubsub::MakeSubscriberConnection(
pubsub::Subscription(std::move(project_id), std::move(subscription_id)),
Options{}
.set<pubsub::RetryPolicyOption>(
/*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(
[](pubsub::Message const& m, pubsub::AckHandler h) {
std::move(h).ack();
std::cout << "Received message " << m << "\n";
PleaseIgnoreThisSimplifiesTestingTheSamples();
});
return std::make_pair(subscriber, std::move(session));
};
google::cloud::internal::ExponentialBackoffPolicy ExponentialBackoffPolicy
A truncated exponential backoff policy with randomized periods.
::google::cloud::internal::LimitedTimeRetryPolicy< pubsub_internal::RetryTraits > LimitedTimeRetryPolicy
A retry policy that limits based on time.
Definition: retry_policy.h:51
std::shared_ptr< SubscriberConnection > MakeSubscriberConnection(Subscription subscription, std::initializer_list< pubsub_internal::NonConstructible >)
Creates a new SubscriberConnection object to work with Subscriber.
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< pubsub_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 the MakeSubscriberConnection function which accepts google::cloud::Options 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 same ConnectionOptions parameters. 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.
auto subscriber = pubsub::Subscriber(pubsub::MakeSubscriberConnection(
pubsub::Subscription(std::move(project_id), std::move(subscription_id)),
Options{}
.set<pubsub::RetryPolicyOption>(
/*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(
[](pubsub::Message const& m, pubsub::AckHandler h) {
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 same ConnectionOptions parameters. 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< pubsub_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 same ConnectionOptions parameters. 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< pubsub_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.