Google Cloud C++ Client  1.32.1
C++ Client Library for Google Cloud Platform
Public Types | Public Member Functions | List of all members
google::cloud::v1::ConnectionOptions< ConnectionTraits > Class Template Reference

The configuration parameters for client connections. More...

#include <google/cloud/connection_options.h>

Public Types

using BackgroundThreadsFactory = ::google::cloud::BackgroundThreadsFactory
 

Public Member Functions

 ConnectionOptions ()
 The default options, using grpc::GoogleDefaultCredentials(). More...
 
 ConnectionOptions (std::shared_ptr< grpc::ChannelCredentials > credentials)
 The default options, using an explicit credentials object. More...
 
ConnectionOptionsset_credentials (std::shared_ptr< grpc::ChannelCredentials > v)
 Change the gRPC credentials value. More...
 
std::shared_ptr< grpc::ChannelCredentials > credentials () const
 The gRPC credentials used by clients configured with this object. More...
 
ConnectionOptionsset_endpoint (std::string v)
 Change the gRPC endpoint. More...
 
std::string const & endpoint () const
 The endpoint used by clients configured with this object. More...
 
int num_channels () const
 The number of transport channels to create. More...
 
ConnectionOptionsset_num_channels (int num_channels)
 Set the value for num_channels(). More...
 
bool tracing_enabled (std::string const &component) const
 Return whether tracing is enabled for the given component. More...
 
ConnectionOptionsenable_tracing (std::string const &component)
 Enable tracing for component in clients configured with this object. More...
 
ConnectionOptionsdisable_tracing (std::string const &component)
 Disable tracing for component in clients configured with this object. More...
 
std::set< std::string > const & components () const
 Return the set of tracing components. More...
 
TracingOptions const & tracing_options () const
 Return the options for use when tracing RPCs. More...
 
std::string const & channel_pool_domain () const
 Define the gRPC channel domain for clients configured with this object. More...
 
ConnectionOptionsset_channel_pool_domain (std::string v)
 Set the value for channel_pool_domain(). More...
 
ConnectionOptionsadd_user_agent_prefix (std::string prefix)
 Prepend prefix to the user-agent string. More...
 
std::string const & user_agent_prefix () const
 Return the current value for the user agent string. More...
 
grpc::ChannelArguments CreateChannelArguments () const
 Create a new grpc::ChannelArguments configured with the options in this object. More...
 
ConnectionOptionsset_background_thread_pool_size (std::size_t s)
 Set the number of background threads. More...
 
std::size_t background_thread_pool_size () const
 
ConnectionOptionsDisableBackgroundThreads (google::cloud::CompletionQueue const &cq)
 Configure the connection to use cq for all background work. More...
 
BackgroundThreadsFactory background_threads_factory () const
 

Detailed Description

template<typename ConnectionTraits>
class google::cloud::v1::ConnectionOptions< ConnectionTraits >

The configuration parameters for client connections.

Definition at line 52 of file connection_options.h.

Member Typedef Documentation

◆ BackgroundThreadsFactory

template<typename ConnectionTraits >
using google::cloud::v1::ConnectionOptions< ConnectionTraits >::BackgroundThreadsFactory = ::google::cloud::BackgroundThreadsFactory

Definition at line 237 of file connection_options.h.

Constructor & Destructor Documentation

◆ ConnectionOptions() [1/2]

template<typename ConnectionTraits >
google::cloud::v1::ConnectionOptions< ConnectionTraits >::ConnectionOptions ( )
inline

The default options, using grpc::GoogleDefaultCredentials().

Definition at line 55 of file connection_options.h.

◆ ConnectionOptions() [2/2]

template<typename ConnectionTraits >
google::cloud::v1::ConnectionOptions< ConnectionTraits >::ConnectionOptions ( std::shared_ptr< grpc::ChannelCredentials >  credentials)
inlineexplicit

The default options, using an explicit credentials object.

Definition at line 58 of file connection_options.h.

Member Function Documentation

◆ add_user_agent_prefix()

template<typename ConnectionTraits >
ConnectionOptions& google::cloud::v1::ConnectionOptions< ConnectionTraits >::add_user_agent_prefix ( std::string  prefix)
inline

Prepend prefix to the user-agent string.

Libraries or services that use Cloud C++ clients may want to set their own user-agent prefix. This can help them develop telemetry information about number of users running particular versions of their system or library.

Definition at line 185 of file connection_options.h.

◆ background_thread_pool_size()

template<typename ConnectionTraits >
std::size_t google::cloud::v1::ConnectionOptions< ConnectionTraits >::background_thread_pool_size ( ) const
inline

Definition at line 215 of file connection_options.h.

◆ background_threads_factory()

template<typename ConnectionTraits >
BackgroundThreadsFactory google::cloud::v1::ConnectionOptions< ConnectionTraits >::background_threads_factory ( ) const
inline

Definition at line 238 of file connection_options.h.

◆ channel_pool_domain()

template<typename ConnectionTraits >
std::string const& google::cloud::v1::ConnectionOptions< ConnectionTraits >::channel_pool_domain ( ) const
inline

Define the gRPC channel domain for clients configured with this object.

In some cases applications may want to use a separate gRPC connections for different clients. gRPC may share the connection used by separate channels created with the same configuration. The client objects created with this object will create gRPC channels configured with grpc.channel_pooling_domain set to the value returned by channel_pool_domain(). gRPC channels with different values for grpc.channel_pooling_domain are guaranteed to use different connections. Note that there is no guarantee that channels with the same value will have the same connection though.

This option might be useful for applications that want to segregate traffic for whatever reason.

Definition at line 168 of file connection_options.h.

◆ components()

template<typename ConnectionTraits >
std::set<std::string> const& google::cloud::v1::ConnectionOptions< ConnectionTraits >::components ( ) const
inline

Return the set of tracing components.

Definition at line 143 of file connection_options.h.

◆ CreateChannelArguments()

template<typename ConnectionTraits >
grpc::ChannelArguments google::cloud::v1::ConnectionOptions< ConnectionTraits >::CreateChannelArguments ( ) const
inline

Create a new grpc::ChannelArguments configured with the options in this object.

The caller would typically pass this argument to grpc::CreateCustomChannel and create one more more gRPC channels.

Definition at line 202 of file connection_options.h.

◆ credentials()

template<typename ConnectionTraits >
std::shared_ptr<grpc::ChannelCredentials> google::cloud::v1::ConnectionOptions< ConnectionTraits >::credentials ( ) const
inline

The gRPC credentials used by clients configured with this object.

Definition at line 80 of file connection_options.h.

◆ disable_tracing()

template<typename ConnectionTraits >
ConnectionOptions& google::cloud::v1::ConnectionOptions< ConnectionTraits >::disable_tracing ( std::string const &  component)
inline

Disable tracing for component in clients configured with this object.

Definition at line 137 of file connection_options.h.

◆ DisableBackgroundThreads()

template<typename ConnectionTraits >
ConnectionOptions& google::cloud::v1::ConnectionOptions< ConnectionTraits >::DisableBackgroundThreads ( google::cloud::CompletionQueue const &  cq)
inline

Configure the connection to use cq for all background work.

Connections need to perform background work on behalf of the application. Normally they just create a background thread and a CompletionQueue for this work, but the application may need more fine-grained control of their threads. In this case the application can provide the CompletionQueue and it assumes responsibility for creating one or more threads blocked on CompletionQueue::Run().

Definition at line 229 of file connection_options.h.

◆ enable_tracing()

template<typename ConnectionTraits >
ConnectionOptions& google::cloud::v1::ConnectionOptions< ConnectionTraits >::enable_tracing ( std::string const &  component)
inline

Enable tracing for component in clients configured with this object.

Definition at line 131 of file connection_options.h.

◆ endpoint()

template<typename ConnectionTraits >
std::string const& google::cloud::v1::ConnectionOptions< ConnectionTraits >::endpoint ( ) const
inline

The endpoint used by clients configured with this object.

Definition at line 99 of file connection_options.h.

◆ num_channels()

template<typename ConnectionTraits >
int google::cloud::v1::ConnectionOptions< ConnectionTraits >::num_channels ( ) const
inline

The number of transport channels to create.

Some transports limit the number of simultaneous calls in progress on a channel (for gRPC the limit is 100). Increasing the number of channels thus increases the number of operations that can be in progress in parallel.

The default value is set by ConnectionTraits::default_num_channels().

Definition at line 111 of file connection_options.h.

◆ set_background_thread_pool_size()

template<typename ConnectionTraits >
ConnectionOptions& google::cloud::v1::ConnectionOptions< ConnectionTraits >::set_background_thread_pool_size ( std::size_t  s)
inline

Set the number of background threads.

Note
This value is not used if DisableBackgroundThreads() is called.

Definition at line 211 of file connection_options.h.

◆ set_channel_pool_domain()

template<typename ConnectionTraits >
ConnectionOptions& google::cloud::v1::ConnectionOptions< ConnectionTraits >::set_channel_pool_domain ( std::string  v)
inline

Set the value for channel_pool_domain().

Definition at line 173 of file connection_options.h.

◆ set_credentials()

template<typename ConnectionTraits >
ConnectionOptions& google::cloud::v1::ConnectionOptions< ConnectionTraits >::set_credentials ( std::shared_ptr< grpc::ChannelCredentials >  v)
inline

Change the gRPC credentials value.

Definition at line 73 of file connection_options.h.

◆ set_endpoint()

template<typename ConnectionTraits >
ConnectionOptions& google::cloud::v1::ConnectionOptions< ConnectionTraits >::set_endpoint ( std::string  v)
inline

Change the gRPC endpoint.

In almost all cases the default is the correct endpoint to use. Applications may need to be changed to (1) test against a fake or simulator, or (2) to use a beta or EAP version of the service.

The default value is set by ConnectionTraits::default_endpoint().

Definition at line 93 of file connection_options.h.

◆ set_num_channels()

template<typename ConnectionTraits >
ConnectionOptions& google::cloud::v1::ConnectionOptions< ConnectionTraits >::set_num_channels ( int  num_channels)
inline

Set the value for num_channels().

Definition at line 114 of file connection_options.h.

◆ tracing_enabled()

template<typename ConnectionTraits >
bool google::cloud::v1::ConnectionOptions< ConnectionTraits >::tracing_enabled ( std::string const &  component) const
inline

Return whether tracing is enabled for the given component.

The C++ clients can log interesting events to help library and application developers troubleshoot problems. This flag returns true if tracing should be enabled by clients configured with this option.

Definition at line 126 of file connection_options.h.

◆ tracing_options()

template<typename ConnectionTraits >
TracingOptions const& google::cloud::v1::ConnectionOptions< ConnectionTraits >::tracing_options ( ) const
inline

Return the options for use when tracing RPCs.

Definition at line 148 of file connection_options.h.

◆ user_agent_prefix()

template<typename ConnectionTraits >
std::string const& google::cloud::v1::ConnectionOptions< ConnectionTraits >::user_agent_prefix ( ) const
inline

Return the current value for the user agent string.

Definition at line 193 of file connection_options.h.