Class ClientOptions (2.20.0)

Configuration options for the Bigtable Client.

Applications typically configure the client class using: ```cpp auto client = bigtable::Client(bigtable::ClientOptions().SetCredentials(...));


<aside class="deprecated"><b>Deprecated:</b>


Please use [`google::cloud::Options`](xref:classgoogle_1_1cloud_1_1Options) instead. 
</aside>

Constructors

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

See Also

grpc::GoogleDefaultCredentials in the grpc documentation

See Also

The documentation for the Cloud Bigtable Emulator.

ClientOptions(Options)

Initialize the client options.

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

Parameter
Name Description
opts Options

(optional) configuration options

ClientOptions(std::shared_ptr< grpc::ChannelCredentials >)

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.

Parameter
Name Description
creds std::shared_ptr< grpc::ChannelCredentials >

gRPC authentication credentials

Functions

data_endpoint() const

Return the current endpoint for data RPCs.

Returns
Type Description
std::string const &

set_data_endpoint(std::string)

Set the current endpoint for data RPCs.

Parameter
Name Description
endpoint std::string
Returns
Type Description
ClientOptions &

admin_endpoint() const

Return the current endpoint for admin RPCs.

Returns
Type Description
std::string const &

set_admin_endpoint(std::string)

Set the current endpoint for admin RPCs.

Parameter
Name Description
endpoint std::string
Returns
Type Description
ClientOptions &

set_connection_pool_name(std::string)

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.

Parameter
Name Description
name std::string
Returns
Type Description
ClientOptions &

connection_pool_name() const

Return the name of the connection pool.

Returns
Type Description
std::string const &

set_connection_pool_size(std::size_t)

Set the size of the connection pool.

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

Parameter
Name Description
size std::size_t
Returns
Type Description
ClientOptions &

connection_pool_size() const

Return the size of the connection pool.

Returns
Type Description
std::size_t

credentials() const

Return the current credentials.

Returns
Type Description
std::shared_ptr< grpc::ChannelCredentials >

SetCredentials(std::shared_ptr< grpc::ChannelCredentials >)

Set the current credentials.

Parameter
Name Description
credentials std::shared_ptr< grpc::ChannelCredentials >
Returns
Type Description
ClientOptions &

channel_arguments() const

Access all the channel arguments.

Returns
Type Description
grpc::ChannelArguments

set_channel_arguments(grpc::ChannelArguments const &)

Set all the channel arguments.

Parameter
Name Description
channel_arguments grpc::ChannelArguments const &
Returns
Type Description
ClientOptions &

SetCompressionAlgorithm(grpc_compression_algorithm)

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.

Parameter
Name Description
algorithm grpc_compression_algorithm
Returns
Type Description
void

SetGrpclbFallbackTimeout(std::chrono::duration< Rep, Period >)

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

For example:

bigtable::ClientOptions::SetGrpclbFallbackTimeout(
    std::chrono::milliseconds(5000))
bigtable::ClientOptions::SetGrpclbFallbackTimeout(
    std::chrono::seconds(5))
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.

Parameters
Name Description
fallback_timeout std::chrono::duration< Rep, Period >
typename Rep

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

typename Period

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

Returns
Type Description
google::cloud::Status

SetUserAgentPrefix(grpc::string const &)

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.

Parameter
Name Description
user_agent_prefix grpc::string const &
Returns
Type Description
void

SetResourceQuota(grpc::ResourceQuota const &)

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.

Parameter
Name Description
resource_quota grpc::ResourceQuota const &
Returns
Type Description
void

SetMaxReceiveMessageSize(int)

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.

Parameter
Name Description
size int
Returns
Type Description
void

SetMaxSendMessageSize(int)

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.

Parameter
Name Description
size int
Returns
Type Description
void

SetLoadBalancingPolicyName(grpc::string const &)

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.

Parameter
Name Description
lb_policy_name grpc::string const &
Returns
Type Description
void

SetServiceConfigJSON(grpc::string const &)

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.

Parameter
Name Description
service_config_json grpc::string const &
Returns
Type Description
void

SetSslTargetNameOverride(grpc::string const &)

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.

Parameter
Name Description
name grpc::string const &
Returns
Type Description
void

tracing_enabled(std::string const &) const

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.

Parameter
Name Description
component std::string const &
Returns
Type Description
bool

enable_tracing(std::string const &)

Enable tracing for component in clients configured with this object.

Parameter
Name Description
component std::string const &
Returns
Type Description
ClientOptions &

disable_tracing(std::string const &)

Disable tracing for component in clients configured with this object.

Parameter
Name Description
component std::string const &
Returns
Type Description
ClientOptions &

tracing_options() const

Return the options for use when tracing RPCs.

Returns
Type Description
TracingOptions const &

max_conn_refresh_period()

Maximum connection refresh period, as set via set_max_conn_refresh_period

Returns
Type Description
std::chrono::milliseconds

set_max_conn_refresh_period(std::chrono::milliseconds)

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:

assert(min_conn_refresh_period() <= max_conn_refresh_period())
Parameter
Name Description
period std::chrono::milliseconds
Returns
Type Description
ClientOptions &

min_conn_refresh_period()

Minimum connection refresh period, as set via set_min_conn_refresh_period

Returns
Type Description
std::chrono::milliseconds

set_min_conn_refresh_period(std::chrono::milliseconds)

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:

assert(min_conn_refresh_period() <= max_conn_refresh_period())
Parameter
Name Description
period std::chrono::milliseconds
Returns
Type Description
ClientOptions &

set_background_thread_pool_size(std::size_t)

Set the number of background threads.

Parameter
Name Description
s std::size_t
Returns
Type Description
ClientOptions &

background_thread_pool_size() const

Return the number of background threads.

Returns
Type Description
std::size_t

DisableBackgroundThreads(google::cloud::CompletionQueue const &)

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().

Parameter
Name Description
cq google::cloud::CompletionQueue const &
Returns
Type Description
ClientOptions &

background_threads_factory() const

Returns
Type Description
BackgroundThreadsFactory

static UserAgentPrefix()

Return the user agent prefix used by the library.

Returns
Type Description
std::string

Type Aliases

BackgroundThreadsFactory

Alias Of: ::google::cloud::BackgroundThreadsFactory

Backwards compatibility alias.