Google Cloud Bigtable C++ Client  1.32.1
A C++ Client Library for Google Cloud Bigtable
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
google::cloud::bigtable::v1::ClientOptions Class Reference

Configuration options for the Bigtable Client. More...

#include <google/cloud/bigtable/client_options.h>

Public Types

using BackgroundThreadsFactory = ::google::cloud::BackgroundThreadsFactory
 Backwards compatibility alias. More...
 

Public Member Functions

 ClientOptions ()
 Initialize the client options. More...
 
 ClientOptions (Options opts)
 Initialize the client options. More...
 
 ClientOptions (std::shared_ptr< grpc::ChannelCredentials > creds)
 Connect to the production instance of Cloud Bigtable using creds. More...
 
std::string const & data_endpoint () const
 Return the current endpoint for data RPCs. More...
 
ClientOptionsset_data_endpoint (std::string endpoint)
 
std::string const & admin_endpoint () const
 Return the current endpoint for admin RPCs. More...
 
ClientOptionsset_admin_endpoint (std::string endpoint)
 
ClientOptionsset_connection_pool_name (std::string name)
 Set the name of the connection pool. More...
 
std::string const & connection_pool_name () const
 Return the name of the connection pool. More...
 
ClientOptionsset_connection_pool_size (std::size_t size)
 Set the size of the connection pool. More...
 
std::size_t connection_pool_size () const
 
std::shared_ptr< grpc::ChannelCredentials > credentials () const
 Return the current credentials. More...
 
ClientOptionsSetCredentials (std::shared_ptr< grpc::ChannelCredentials > credentials)
 
grpc::ChannelArguments channel_arguments () const
 Access all the channel arguments. More...
 
ClientOptionsset_channel_arguments (grpc::ChannelArguments const &channel_arguments)
 Set all the channel arguments. More...
 
void SetCompressionAlgorithm (grpc_compression_algorithm algorithm)
 Set compression algorithm for channel. More...
 
template<typename Rep , typename Period >
google::cloud::Status SetGrpclbFallbackTimeout (std::chrono::duration< Rep, Period > fallback_timeout)
 Set the grpclb fallback timeout with the timestamp fallback_timeout for the channel. More...
 
void SetUserAgentPrefix (grpc::string const &user_agent_prefix)
 Set the string to prepend to the user agent. More...
 
void SetResourceQuota (grpc::ResourceQuota const &resource_quota)
 Set the buffer pool to be attached to the constructed channel. More...
 
void SetMaxReceiveMessageSize (int size)
 Set the max receive message size in bytes. More...
 
void SetMaxSendMessageSize (int size)
 Set the max send message size in bytes. More...
 
void SetLoadBalancingPolicyName (grpc::string const &lb_policy_name)
 Set LB policy name. More...
 
void SetServiceConfigJSON (grpc::string const &service_config_json)
 Set service config in JSON form. More...
 
void SetSslTargetNameOverride (grpc::string const &name)
 Set target name override for SSL host name checking. More...
 
bool tracing_enabled (std::string const &component) const
 Return whether tracing is enabled for the given component. More...
 
ClientOptionsenable_tracing (std::string const &component)
 Enable tracing for component in clients configured with this object. More...
 
ClientOptionsdisable_tracing (std::string const &component)
 Disable tracing for component in clients configured with this object. More...
 
TracingOptions const & tracing_options () const
 Return the options for use when tracing RPCs. More...
 
std::chrono::milliseconds max_conn_refresh_period ()
 Maximum connection refresh period, as set via set_max_conn_refresh_period More...
 
ClientOptionsset_max_conn_refresh_period (std::chrono::milliseconds period)
 If set to a positive number, the client will refresh connections at random moments not more apart from each other than this duration. More...
 
std::chrono::milliseconds min_conn_refresh_period ()
 Minimum connection refresh period, as set via set_min_conn_refresh_period More...
 
ClientOptionsset_min_conn_refresh_period (std::chrono::milliseconds period)
 Configures the minimum connection refresh period. More...
 
ClientOptionsset_background_thread_pool_size (std::size_t s)
 Set the number of background threads. More...
 
std::size_t background_thread_pool_size () const
 
ClientOptionsDisableBackgroundThreads (google::cloud::CompletionQueue const &cq)
 Configure the connection to use cq for all background work. More...
 
BackgroundThreadsFactory background_threads_factory () const
 

Static Public Member Functions

static std::string UserAgentPrefix ()
 Return the user agent prefix used by the library. More...
 

Friends

struct ClientOptionsTestTraits
 

Detailed Description

Configuration options for the Bigtable Client.

Applications typically configure the client class using:

auto client =
bigtable::Client(bigtable::ClientOptions().SetCredentials(...));
ClientOptions & SetCredentials(std::shared_ptr< grpc::ChannelCredentials > credentials)

Definition at line 54 of file client_options.h.

Member Typedef Documentation

◆ BackgroundThreadsFactory

using google::cloud::bigtable::v1::ClientOptions::BackgroundThreadsFactory = ::google::cloud::BackgroundThreadsFactory

Backwards compatibility alias.

Deprecated:
Consider using google::cloud::BackgroundThreadsFactory directly

Definition at line 464 of file client_options.h.

Constructor & Destructor Documentation

◆ ClientOptions() [1/3]

google::cloud::bigtable::v1::ClientOptions::ClientOptions ( )

Initialize the client options.

Configure the client to connect to the Cloud Bigtable service, using the default options.

Environment Variables
If the BIGTABLE_EMULATOR_HOST environment variable is set, the default configuration changes in important ways:
  • The credentials are initialized to grpc::InsecureCredentials().
  • Any client created with these objects will connect to the endpoint (typically just a host:port string) set in the environment variable.

This makes it easy to test applications using the Cloud Bigtable Emulator.

See also
The Google Cloud Platform introduction to application default credentials
grpc::GoogleDefaultCredentials in the grpc documentation
The documentation for the Cloud Bigtable Emulator.

Definition at line 39 of file client_options.cc.

◆ ClientOptions() [2/3]

google::cloud::bigtable::v1::ClientOptions::ClientOptions ( Options  opts)
explicit

Initialize the client options.

Expected options are any of the types in the following option lists.

Note
Unrecognized options will be ignored. To debug issues with options set GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes in the environment and unexpected options will be logged.
Parameters
opts(optional) configuration options

Definition at line 41 of file client_options.cc.

◆ ClientOptions() [3/3]

google::cloud::bigtable::v1::ClientOptions::ClientOptions ( std::shared_ptr< grpc::ChannelCredentials >  creds)
explicit

Connect to the production instance of Cloud Bigtable using creds.

This constructor always connects to the production instance of Cloud Bigtable, and can be used when the application default credentials are not configured in the environment where the application is running.

Note
Prefer using the ClientOptions(Options opts) constructor and passing in creds as a GrpcCredentialOption.
Parameters
credsgRPC authentication credentials

Definition at line 47 of file client_options.cc.

Member Function Documentation

◆ admin_endpoint()

std::string const& google::cloud::bigtable::v1::ClientOptions::admin_endpoint ( ) const
inline

Return the current endpoint for admin RPCs.

Definition at line 124 of file client_options.h.

◆ background_thread_pool_size()

std::size_t google::cloud::bigtable::v1::ClientOptions::background_thread_pool_size ( ) const
inline

Definition at line 441 of file client_options.h.

◆ background_threads_factory()

BackgroundThreadsFactory google::cloud::bigtable::v1::ClientOptions::background_threads_factory ( ) const

Definition at line 70 of file client_options.cc.

◆ channel_arguments()

grpc::ChannelArguments google::cloud::bigtable::v1::ClientOptions::channel_arguments ( ) const
inline

Access all the channel arguments.

Definition at line 181 of file client_options.h.

◆ connection_pool_name()

std::string const& google::cloud::bigtable::v1::ClientOptions::connection_pool_name ( ) const
inline

Return the name of the connection pool.

Definition at line 153 of file client_options.h.

◆ connection_pool_size()

std::size_t google::cloud::bigtable::v1::ClientOptions::connection_pool_size ( ) const
inline

Definition at line 165 of file client_options.h.

◆ credentials()

std::shared_ptr<grpc::ChannelCredentials> google::cloud::bigtable::v1::ClientOptions::credentials ( ) const
inline

Return the current credentials.

Definition at line 170 of file client_options.h.

◆ data_endpoint()

std::string const& google::cloud::bigtable::v1::ClientOptions::data_endpoint ( ) const
inline

Return the current endpoint for data RPCs.

Definition at line 114 of file client_options.h.

◆ disable_tracing()

ClientOptions& google::cloud::bigtable::v1::ClientOptions::disable_tracing ( std::string const &  component)
inline

Disable tracing for component in clients configured with this object.

Definition at line 371 of file client_options.h.

◆ DisableBackgroundThreads()

ClientOptions & google::cloud::bigtable::v1::ClientOptions::DisableBackgroundThreads ( google::cloud::CompletionQueue const &  cq)

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 64 of file client_options.cc.

◆ enable_tracing()

ClientOptions& google::cloud::bigtable::v1::ClientOptions::enable_tracing ( std::string const &  component)
inline

Enable tracing for component in clients configured with this object.

Definition at line 365 of file client_options.h.

◆ max_conn_refresh_period()

std::chrono::milliseconds google::cloud::bigtable::v1::ClientOptions::max_conn_refresh_period ( )
inline

Maximum connection refresh period, as set via set_max_conn_refresh_period

Definition at line 384 of file client_options.h.

◆ min_conn_refresh_period()

std::chrono::milliseconds google::cloud::bigtable::v1::ClientOptions::min_conn_refresh_period ( )
inline

Minimum connection refresh period, as set via set_min_conn_refresh_period

Definition at line 410 of file client_options.h.

◆ set_admin_endpoint()

ClientOptions& google::cloud::bigtable::v1::ClientOptions::set_admin_endpoint ( std::string  endpoint)
inline

Definition at line 128 of file client_options.h.

◆ set_background_thread_pool_size()

ClientOptions& google::cloud::bigtable::v1::ClientOptions::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 436 of file client_options.h.

◆ set_channel_arguments()

ClientOptions& google::cloud::bigtable::v1::ClientOptions::set_channel_arguments ( grpc::ChannelArguments const &  channel_arguments)
inline

Set all the channel arguments.

Definition at line 186 of file client_options.h.

◆ set_connection_pool_name()

ClientOptions& google::cloud::bigtable::v1::ClientOptions::set_connection_pool_name ( std::string  name)
inline

Set the name of the connection pool.

gRPC typically opens a single connection for each destination. To improve performance, the Cloud Bigtable C++ client can open multiple connections to a given destination, but these connections are shared by all threads in the application. Sometimes the application may want even more segregation, for example, the application may want to use a different pool for high-priority requests vs. lower priority ones. Using different names creates segregated pools.

Definition at line 147 of file client_options.h.

◆ set_connection_pool_size()

ClientOptions & google::cloud::bigtable::v1::ClientOptions::set_connection_pool_size ( std::size_t  size)

Set the size of the connection pool.

Specifying 0 for size will set the size of the connection pool to default.

Definition at line 54 of file client_options.cc.

◆ set_data_endpoint()

ClientOptions& google::cloud::bigtable::v1::ClientOptions::set_data_endpoint ( std::string  endpoint)
inline

Definition at line 118 of file client_options.h.

◆ set_max_conn_refresh_period()

ClientOptions& google::cloud::bigtable::v1::ClientOptions::set_max_conn_refresh_period ( std::chrono::milliseconds  period)
inline

If set to a positive number, the client will refresh connections at random moments not more apart from each other than this duration.

This is necessary to avoid all connections simultaneously expiring and causing latency spikes.

If needed it changes max_conn_refresh_period() to preserve the invariant:

std::chrono::milliseconds min_conn_refresh_period()
Minimum connection refresh period, as set via set_min_conn_refresh_period
std::chrono::milliseconds max_conn_refresh_period()
Maximum connection refresh period, as set via set_max_conn_refresh_period

Definition at line 400 of file client_options.h.

◆ set_min_conn_refresh_period()

ClientOptions& google::cloud::bigtable::v1::ClientOptions::set_min_conn_refresh_period ( std::chrono::milliseconds  period)
inline

Configures the minimum connection refresh period.

The library will wait at least this long before attempting any refresh operation.

If needed it changes max_conn_refresh_period() to preserve the invariant:

Definition at line 424 of file client_options.h.

◆ SetCompressionAlgorithm()

void google::cloud::bigtable::v1::ClientOptions::SetCompressionAlgorithm ( grpc_compression_algorithm  algorithm)
inline

Set compression algorithm for channel.

Please see the docs for grpc::ChannelArguments::SetCompressionAlgorithm() on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more details.

Definition at line 200 of file client_options.h.

◆ SetCredentials()

ClientOptions& google::cloud::bigtable::v1::ClientOptions::SetCredentials ( std::shared_ptr< grpc::ChannelCredentials >  credentials)
inline

Definition at line 174 of file client_options.h.

◆ SetGrpclbFallbackTimeout()

template<typename Rep , typename Period >
google::cloud::Status google::cloud::bigtable::v1::ClientOptions::SetGrpclbFallbackTimeout ( std::chrono::duration< Rep, Period >  fallback_timeout)
inline

Set the grpclb fallback timeout with the timestamp fallback_timeout for the channel.

For example:

bigtable::ClientOptions::SetGrpclbFallbackTimeout(
std::chrono::milliseconds(5000))
std::chrono::seconds(5))
google::cloud::Status SetGrpclbFallbackTimeout(std::chrono::duration< Rep, Period > fallback_timeout)
Set the grpclb fallback timeout with the timestamp fallback_timeout for the channel.
ClientOptions()
Initialize the client options.
Template Parameters
Repa placeholder to match the Rep tparam for fallback_timeout, the semantics of this template parameter are documented in std::chrono::duration<> (in brief, the underlying arithmetic type used to store the number of ticks), for our purposes it is simply a formal parameter.
Perioda placeholder to match the Period tparam for fallback_timeout, the semantics of this template parameter are documented in std::chrono::duration<> (in brief, the length of the tick in seconds, expressed as a std::ratio<>), for our purposes it is simply a formal parameter.
See also
std::chrono::duration<> for more details.

Please see the docs for grpc::ChannelArguments::SetGrpclbFallbackTimeout() on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more details.

Definition at line 240 of file client_options.h.

◆ SetLoadBalancingPolicyName()

void google::cloud::bigtable::v1::ClientOptions::SetLoadBalancingPolicyName ( grpc::string const &  lb_policy_name)
inline

Set LB policy name.

Please see the docs for grpc::ChannelArguments::SetLoadBalancingPolicyName() on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more details.

Definition at line 318 of file client_options.h.

◆ SetMaxReceiveMessageSize()

void google::cloud::bigtable::v1::ClientOptions::SetMaxReceiveMessageSize ( int  size)
inline

Set the max receive message size in bytes.

-1 means unlimited.

Please see the docs for grpc::ChannelArguments::SetMaxReceiveMessageSize() on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more details.

Definition at line 291 of file client_options.h.

◆ SetMaxSendMessageSize()

void google::cloud::bigtable::v1::ClientOptions::SetMaxSendMessageSize ( int  size)
inline

Set the max send message size in bytes.

-1 means unlimited.

Please see the docs for grpc::ChannelArguments::SetMaxSendMessageSize() on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more details.

Definition at line 304 of file client_options.h.

◆ SetResourceQuota()

void google::cloud::bigtable::v1::ClientOptions::SetResourceQuota ( grpc::ResourceQuota const &  resource_quota)
inline

Set the buffer pool to be attached to the constructed channel.

Please see the docs for grpc::ChannelArguments::SetResourceQuota() on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more details.

Definition at line 277 of file client_options.h.

◆ SetServiceConfigJSON()

void google::cloud::bigtable::v1::ClientOptions::SetServiceConfigJSON ( grpc::string const &  service_config_json)
inline

Set service config in JSON form.

Please see the docs for grpc::ChannelArguments::SetServiceConfigJSON() on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more details.

Definition at line 331 of file client_options.h.

◆ SetSslTargetNameOverride()

void google::cloud::bigtable::v1::ClientOptions::SetSslTargetNameOverride ( grpc::string const &  name)
inline

Set target name override for SSL host name checking.

Please see the docs for grpc::ChannelArguments::SetSslTargetNameOverride() on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more details.

Definition at line 344 of file client_options.h.

◆ SetUserAgentPrefix()

void google::cloud::bigtable::v1::ClientOptions::SetUserAgentPrefix ( grpc::string const &  user_agent_prefix)
inline

Set the string to prepend to the user agent.

Please see the docs for grpc::ChannelArguments::SetUserAgentPrefix() on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more details.

Definition at line 264 of file client_options.h.

◆ tracing_enabled()

bool google::cloud::bigtable::v1::ClientOptions::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 359 of file client_options.h.

◆ tracing_options()

TracingOptions const& google::cloud::bigtable::v1::ClientOptions::tracing_options ( ) const
inline

Return the options for use when tracing RPCs.

Definition at line 377 of file client_options.h.

◆ UserAgentPrefix()

std::string google::cloud::bigtable::v1::ClientOptions::UserAgentPrefix ( )
static

Return the user agent prefix used by the library.

Definition at line 60 of file client_options.cc.

Friends And Related Function Documentation

◆ ClientOptionsTestTraits

friend struct ClientOptionsTestTraits
friend

Definition at line 469 of file client_options.h.