Google Cloud Bigtable C++ Client 2.13.0
A C++ Client Library for Google Cloud Bigtable
Loading...
Searching...
No Matches
client_options.h
1// Copyright 2017 Google Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_CLIENT_OPTIONS_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_CLIENT_OPTIONS_H
17
18#include "google/cloud/bigtable/options.h"
19#include "google/cloud/bigtable/version.h"
20#include "google/cloud/background_threads.h"
21#include "google/cloud/common_options.h"
22#include "google/cloud/completion_queue.h"
23#include "google/cloud/grpc_options.h"
24#include "google/cloud/internal/algorithm.h"
25#include "google/cloud/options.h"
26#include "google/cloud/status.h"
27#include "google/cloud/tracing_options.h"
28#include "absl/strings/str_split.h"
29#include <grpcpp/grpcpp.h>
30#include <grpcpp/resource_quota.h>
31#include <chrono>
32#include <set>
33#include <string>
34
35namespace google {
36namespace cloud {
37namespace bigtable {
38GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
39class ClientOptions;
40namespace internal {
41Options&& MakeOptions(ClientOptions&& o);
42} // namespace internal
43
44/**
45 * Configuration options for the Bigtable Client.
46 *
47 * Applications typically configure the client class using:
48 * @code
49 * auto client =
50 * bigtable::Client(bigtable::ClientOptions().SetCredentials(...));
51 * @endcode
52 *
53 * @deprecated Please use `google::cloud::Options` instead.
54 */
55class ClientOptions {
56 public:
57 /**
58 * Initialize the client options.
59 *
60 * Configure the client to connect to the Cloud Bigtable service, using the
61 * default options.
62 *
63 * @par Environment Variables
64 * If the `BIGTABLE_EMULATOR_HOST` environment variable is set, the default
65 * configuration changes in important ways:
66 *
67 * - The credentials are initialized to `grpc::InsecureCredentials()`.
68 * - Any client created with these objects will connect to the endpoint
69 * (typically just a `host:port` string) set in the environment variable.
70 *
71 * This makes it easy to test applications using the Cloud Bigtable Emulator.
72 *
73 * @see The Google Cloud Platform introduction to
74 * [application default
75 * credentials](https://cloud.google.com/docs/authentication/production)
76 * @see `grpc::GoogleDefaultCredentials` in the [grpc
77 * documentation](https://grpc.io/grpc/cpp/namespacegrpc.html)
78 * @see The [documentation](https://cloud.google.com/bigtable/docs/emulator)
79 * for the Cloud Bigtable Emulator.
80 *
81 * @deprecated Please use `google::cloud::Options` instead.
82 */
83 GOOGLE_CLOUD_CPP_DEPRECATED("use `google::cloud::Options` instead")
85
86 /**
87 * Initialize the client options.
88 *
89 * Expected options are any of the types in the following option lists.
90 *
91 * - `google::cloud::CommonOptionList`
92 * - `google::cloud::GrpcOptionList`
93 * - `google::cloud::bigtable::ClientOptionList`
94 *
95 * @note Unrecognized options will be ignored. To debug issues with options
96 * set `GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes` in the environment and
97 * unexpected options will be logged.
98 *
99 * @param opts (optional) configuration options
100 *
101 * @deprecated Please use `google::cloud::Options` directly instead.
102 */
103 GOOGLE_CLOUD_CPP_DEPRECATED("use `google::cloud::Options` directly instead")
104 explicit ClientOptions(Options opts);
105
106 /**
107 * Connect to the production instance of Cloud Bigtable using @p creds.
108 *
109 * This constructor always connects to the production instance of Cloud
110 * Bigtable, and can be used when the application default credentials are
111 * not configured in the environment where the application is running.
112 *
113 * @param creds gRPC authentication credentials
114 *
115 * @deprecated Please configure `google::cloud::Options` with
116 * `google::cloud::GrpcCredentialOption` instead.
117 */
118 GOOGLE_CLOUD_CPP_DEPRECATED(
119 "use `google::cloud::Options` with `google::cloud::GrpcCredentialOption` "
120 "instead")
121 explicit ClientOptions(std::shared_ptr<grpc::ChannelCredentials> creds);
122
123 /**
124 * Return the current endpoint for data RPCs.
125 *
126 * @deprecated Please configure `google::cloud::Options` with
127 * `google::cloud::EndpointOption` instead.
128 */
129 GOOGLE_CLOUD_CPP_DEPRECATED(
130 "use `google::cloud::Options` with `google::cloud::EndpointOption` "
131 "instead")
132 std::string const& data_endpoint() const {
133 return opts_.get<DataEndpointOption>();
134 }
135
136 /**
137 * Set the current endpoint for data RPCs.
138 *
139 * @deprecated Please configure `google::cloud::Options` with
140 * `google::cloud::EndpointOption` instead.
141 */
142 GOOGLE_CLOUD_CPP_DEPRECATED(
143 "use `google::cloud::Options` with `google::cloud::EndpointOption` "
144 "instead")
145 ClientOptions& set_data_endpoint(std::string endpoint) {
146 opts_.set<DataEndpointOption>(std::move(endpoint));
147 return *this;
148 }
149
150 /**
151 * Return the current endpoint for admin RPCs.
152 *
153 * @deprecated Please configure `google::cloud::Options` with
154 * `google::cloud::EndpointOption` instead.
155 */
156 GOOGLE_CLOUD_CPP_DEPRECATED(
157 "use `google::cloud::Options` with `google::cloud::EndpointOption` "
158 "instead")
159 std::string const& admin_endpoint() const {
160 return opts_.get<AdminEndpointOption>();
161 }
162
163 /**
164 * Set the current endpoint for admin RPCs.
165 *
166 * @deprecated Please configure `google::cloud::Options` with
167 * `google::cloud::EndpointOption` instead.
168 */
169 GOOGLE_CLOUD_CPP_DEPRECATED(
170 "use `google::cloud::Options` with `google::cloud::EndpointOption` "
171 "instead")
172 ClientOptions& set_admin_endpoint(std::string endpoint) {
173 opts_.set<AdminEndpointOption>(endpoint);
174 // These two endpoints are generally equivalent, but they may differ in
175 // some tests.
176 opts_.set<InstanceAdminEndpointOption>(std::move(endpoint));
177 return *this;
178 }
179
180 /**
181 * Set the name of the connection pool.
182 *
183 * gRPC typically opens a single connection for each destination. To improve
184 * performance, the Cloud Bigtable C++ client can open multiple connections
185 * to a given destination, but these connections are shared by all threads
186 * in the application. Sometimes the application may want even more
187 * segregation, for example, the application may want to use a different pool
188 * for high-priority requests vs. lower priority ones. Using different names
189 * creates segregated pools.
190 *
191 * @deprecated Please configure `google::cloud::Options` with
192 * `google::cloud::GrpcChannelArgumentsOption` or
193 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
194 */
195 GOOGLE_CLOUD_CPP_DEPRECATED(
196 "use `google::cloud::Options` with "
197 "`google::cloud::GrpcChannelArgumentsOption` or "
198 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
199 ClientOptions& set_connection_pool_name(std::string name) {
200 connection_pool_name_ = std::move(name);
201 return *this;
202 }
203
204 /**
205 * Return the name of the connection pool.
206 *
207 * @deprecated Please configure `google::cloud::Options` with
208 * `google::cloud::GrpcChannelArgumentsOption` or
209 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
210 */
211 GOOGLE_CLOUD_CPP_DEPRECATED(
212 "use `google::cloud::Options` with "
213 "`google::cloud::GrpcChannelArgumentsOption` or "
214 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
215 std::string const& connection_pool_name() const {
216 return connection_pool_name_;
217 }
218
219 /**
220 * Set the size of the connection pool.
221 *
222 * Specifying 0 for @p size will set the size of the connection pool to
223 * default.
224 *
225 * @deprecated Please configure `google::cloud::Options` with
226 * `google::cloud::GrpcNumChannelsOption` instead.
227 */
228 GOOGLE_CLOUD_CPP_DEPRECATED(
229 "use `google::cloud::Options` with "
230 "`google::cloud::GrpcNumChannelsOption` instead")
231 ClientOptions& set_connection_pool_size(std::size_t size);
232
233 /**
234 * Return the size of the connection pool.
235 *
236 * @deprecated Please configure `google::cloud::Options` with
237 * `google::cloud::GrpcNumChannelsOption` instead.
238 */
239 GOOGLE_CLOUD_CPP_DEPRECATED(
240 "use `google::cloud::Options` with "
241 "`google::cloud::GrpcNumChannelsOption` instead")
242 std::size_t connection_pool_size() const {
244 }
245
246 /**
247 * Return the current credentials.
248 *
249 * @deprecated Please configure `google::cloud::Options` with
250 * `google::cloud::GrpcCredentialOption` instead.
251 */
252 GOOGLE_CLOUD_CPP_DEPRECATED(
253 "use `google::cloud::Options` with "
254 "`google::cloud::GrpcCredentialOption` instead")
255 std::shared_ptr<grpc::ChannelCredentials> credentials() const {
257 }
258
259 /**
260 * Set the current credentials.
261 *
262 * @deprecated Please configure `google::cloud::Options` with
263 * `google::cloud::GrpcCredentialOption` instead.
264 */
265 GOOGLE_CLOUD_CPP_DEPRECATED(
266 "use `google::cloud::Options` with "
267 "`google::cloud::GrpcCredentialOption` instead")
269 std::shared_ptr<grpc::ChannelCredentials> credentials) {
270 opts_.set<GrpcCredentialOption>(std::move(credentials));
271 return *this;
272 }
273
274 /**
275 * Access all the channel arguments.
276 *
277 * @deprecated Please configure `google::cloud::Options` with
278 * `google::cloud::GrpcChannelArgumentsOption` or
279 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
280 */
281 GOOGLE_CLOUD_CPP_DEPRECATED(
282 "use `google::cloud::Options` with "
283 "`google::cloud::GrpcChannelArgumentsOption` or "
284 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
285 grpc::ChannelArguments channel_arguments() const {
286 return ::google::cloud::internal::MakeChannelArguments(opts_);
287 }
288
289 /**
290 * Set all the channel arguments.
291 *
292 * @deprecated Please configure `google::cloud::Options` with
293 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
294 */
295 GOOGLE_CLOUD_CPP_DEPRECATED(
296 "use `google::cloud::Options` with "
297 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
299 grpc::ChannelArguments const& channel_arguments) {
300 opts_.set<GrpcChannelArgumentsNativeOption>(channel_arguments);
301 return *this;
302 }
303
304 /**
305 * Set compression algorithm for channel.
306 *
307 * Please see the docs for grpc::ChannelArguments::SetCompressionAlgorithm()
308 * on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html
309 * for more details.
310 *
311 * @deprecated Please configure `google::cloud::Options` with
312 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
313 */
314 GOOGLE_CLOUD_CPP_DEPRECATED(
315 "use `google::cloud::Options` with "
316 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
317 void SetCompressionAlgorithm(grpc_compression_algorithm algorithm) {
318 opts_.lookup<GrpcChannelArgumentsNativeOption>().SetCompressionAlgorithm(
319 algorithm);
320 }
321
322 /**
323 * Set the `grpclb` fallback timeout with the timestamp @p fallback_timeout
324 * for the channel.
325 *
326 * For example:
327 *
328 * @code
329 * bigtable::ClientOptions::SetGrpclbFallbackTimeout(
330 * std::chrono::milliseconds(5000))
331 * bigtable::ClientOptions::SetGrpclbFallbackTimeout(
332 * std::chrono::seconds(5))
333 * @endcode
334 *
335 * @tparam Rep a placeholder to match the Rep tparam for @p fallback_timeout,
336 * the semantics of this template parameter are documented in
337 * `std::chrono::duration<>` (in brief, the underlying arithmetic type
338 * used to store the number of ticks), for our purposes it is simply a
339 * formal parameter.
340 * @tparam Period a placeholder to match the Period tparam for @p
341 * fallback_timeout, the semantics of this template parameter are
342 * documented in `std::chrono::duration<>` (in brief, the length of the
343 * tick in seconds, expressed as a `std::ratio<>`), for our purposes it
344 * is simply a formal parameter.
345 *
346 * @see
347 * [std::chrono::duration<>](http://en.cppreference.com/w/cpp/chrono/duration)
348 * for more details.
349 *
350 * Please see the docs for
351 * `grpc::ChannelArguments::SetGrpclbFallbackTimeout()` on
352 * https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more
353 * details.
354 *
355 * @deprecated Please configure `google::cloud::Options` with
356 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
357 */
358 template <typename Rep, typename Period>
359 GOOGLE_CLOUD_CPP_DEPRECATED(
360 "use `google::cloud::Options` with "
361 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
363 std::chrono::duration<Rep, Period> fallback_timeout) {
364 std::chrono::milliseconds ft_ms =
365 std::chrono::duration_cast<std::chrono::milliseconds>(fallback_timeout);
366
367 if (ft_ms.count() > std::numeric_limits<int>::max()) {
369 "The supplied duration is larger than the "
370 "maximum value allowed by gRPC (INT_MAX)");
371 }
372 auto fallback_timeout_ms = static_cast<int>(ft_ms.count());
373 opts_.lookup<GrpcChannelArgumentsNativeOption>().SetGrpclbFallbackTimeout(
374 fallback_timeout_ms);
376 }
377
378 /**
379 * Set the string to prepend to the user agent.
380 *
381 * Please see the docs for `grpc::ChannelArguments::SetUserAgentPrefix()`
382 * on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html
383 * for more details.
384 *
385 * @deprecated Please configure `google::cloud::Options` with
386 * `google::cloud::UserAgentProductsOption` or
387 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
388 */
389 GOOGLE_CLOUD_CPP_DEPRECATED(
390 "use `google::cloud::Options` with "
391 "`google::cloud::UserAgentProductsOption` "
392 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
393 void SetUserAgentPrefix(grpc::string const& user_agent_prefix) {
394 opts_.lookup<GrpcChannelArgumentsNativeOption>().SetUserAgentPrefix(
395 user_agent_prefix);
396 }
397
398 /**
399 * Set the buffer pool to be attached to the constructed channel.
400 *
401 * Please see the docs for `grpc::ChannelArguments::SetResourceQuota()`
402 * on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html
403 * for more details.
404 *
405 * @deprecated Please configure `google::cloud::Options` with
406 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
407 */
408 GOOGLE_CLOUD_CPP_DEPRECATED(
409 "use `google::cloud::Options` with "
410 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
411 void SetResourceQuota(grpc::ResourceQuota const& resource_quota) {
413 resource_quota);
414 }
415
416 /**
417 * Set the max receive message size in bytes. -1 means unlimited.
418 *
419 * Please see the docs for
420 * `grpc::ChannelArguments::SetMaxReceiveMessageSize()` on
421 * https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html for more
422 * details.
423 *
424 * @deprecated Please configure `google::cloud::Options` with
425 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
426 */
427 GOOGLE_CLOUD_CPP_DEPRECATED(
428 "use `google::cloud::Options` with "
429 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
430 void SetMaxReceiveMessageSize(int size) {
431 opts_.lookup<GrpcChannelArgumentsNativeOption>().SetMaxReceiveMessageSize(
432 size);
433 }
434
435 /**
436 * Set the max send message size in bytes. -1 means unlimited.
437 *
438 * Please see the docs for grpc::ChannelArguments::SetMaxSendMessageSize()
439 * on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html
440 * for more details.
441 *
442 * @deprecated Please configure `google::cloud::Options` with
443 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
444 */
445 GOOGLE_CLOUD_CPP_DEPRECATED(
446 "use `google::cloud::Options` with "
447 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
448 void SetMaxSendMessageSize(int size) {
449 opts_.lookup<GrpcChannelArgumentsNativeOption>().SetMaxSendMessageSize(
450 size);
451 }
452
453 /**
454 * Set LB policy name.
455 *
456 * Please see the docs for
457 * grpc::ChannelArguments::SetLoadBalancingPolicyName()
458 * on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html
459 * for more details.
460 *
461 * @deprecated Please configure `google::cloud::Options` with
462 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
463 */
464 GOOGLE_CLOUD_CPP_DEPRECATED(
465 "use `google::cloud::Options` with "
466 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
467 void SetLoadBalancingPolicyName(grpc::string const& lb_policy_name) {
468 opts_.lookup<GrpcChannelArgumentsNativeOption>().SetLoadBalancingPolicyName(
469 lb_policy_name);
470 }
471
472 /**
473 * Set service config in JSON form.
474 *
475 * Please see the docs for grpc::ChannelArguments::SetServiceConfigJSON()
476 * on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html
477 * for more details.
478 *
479 * @deprecated Please configure `google::cloud::Options` with
480 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
481 */
482 GOOGLE_CLOUD_CPP_DEPRECATED(
483 "use `google::cloud::Options` with "
484 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
485 void SetServiceConfigJSON(grpc::string const& service_config_json) {
486 opts_.lookup<GrpcChannelArgumentsNativeOption>().SetServiceConfigJSON(
487 service_config_json);
488 }
489
490 /**
491 * Set target name override for SSL host name checking.
492 *
493 * Please see the docs for grpc::ChannelArguments::SetSslTargetNameOverride()
494 * on https://grpc.io/grpc/cpp/classgrpc_1_1_channel_arguments.html
495 * for more details.
496 *
497 * @deprecated Please configure `google::cloud::Options` with
498 * `google::cloud::GrpcChannelArgumentsNativeOption` instead.
499 */
500 GOOGLE_CLOUD_CPP_DEPRECATED(
501 "use `google::cloud::Options` with "
502 "`google::cloud::GrpcChannelArgumentsNativeOption` instead")
503 void SetSslTargetNameOverride(grpc::string const& name) {
504 opts_.lookup<GrpcChannelArgumentsNativeOption>().SetSslTargetNameOverride(
505 name);
506 }
507
508 /// Return the user agent prefix used by the library.
509 GOOGLE_CLOUD_CPP_DEPRECATED("Not intended for use in application code")
510 static std::string UserAgentPrefix();
511
512 /**
513 * Return whether tracing is enabled for the given @p component.
514 *
515 * The C++ clients can log interesting events to help library and application
516 * developers troubleshoot problems. This flag returns true if tracing should
517 * be enabled by clients configured with this option.
518 *
519 * @deprecated Please configure `google::cloud::Options` with
520 * `google::cloud::TracingComponentsOption` instead.
521 */
522 GOOGLE_CLOUD_CPP_DEPRECATED(
523 "use `google::cloud::Options` with "
524 "`google::cloud::TracingComponentsOption` instead")
525 bool tracing_enabled(std::string const& component) const {
526 return google::cloud::internal::Contains(
527 opts_.get<TracingComponentsOption>(), component);
528 }
529
530 /**
531 * Enable tracing for @p component in clients configured with this object.
532 *
533 * @deprecated Please configure `google::cloud::Options` with
534 * `google::cloud::TracingComponentsOption` instead.
535 */
536 GOOGLE_CLOUD_CPP_DEPRECATED(
537 "use `google::cloud::Options` with "
538 "`google::cloud::TracingComponentsOption` instead")
539 ClientOptions& enable_tracing(std::string const& component) {
540 opts_.lookup<TracingComponentsOption>().insert(component);
541 return *this;
542 }
543
544 /**
545 * Disable tracing for @p component in clients configured with this object.
546 *
547 * @deprecated Please configure `google::cloud::Options` with
548 * `google::cloud::TracingComponentsOption` instead.
549 */
550 GOOGLE_CLOUD_CPP_DEPRECATED(
551 "use `google::cloud::Options` with "
552 "`google::cloud::TracingComponentsOption` instead")
553 ClientOptions& disable_tracing(std::string const& component) {
554 opts_.lookup<TracingComponentsOption>().erase(component);
555 return *this;
556 }
557
558 /**
559 * Return the options for use when tracing RPCs.
560 *
561 * @deprecated Please configure `google::cloud::Options` with
562 * `google::cloud::GrpcTracingOptionsOption` instead.
563 */
564 GOOGLE_CLOUD_CPP_DEPRECATED(
565 "use `google::cloud::Options` with "
566 "`google::cloud::GrpcTracingOptionsOption` instead")
567 TracingOptions const& tracing_options() const {
569 }
570
571 /**
572 * Maximum connection refresh period, as set via `set_max_conn_refresh_period`
573 *
574 * @deprecated Please configure `google::cloud::Options` with
575 * `bigtable::MinConnectionRefreshOption` and
576 * `bigtable::MaxConnectionRefreshOption` instead.
577 */
578 GOOGLE_CLOUD_CPP_DEPRECATED(
579 "use `google::cloud::Options` with `MinConnectionRefreshOption` and "
580 "`MaxConnectionRefreshOption` instead")
581 std::chrono::milliseconds max_conn_refresh_period() {
583 }
584
585 /**
586 * If set to a positive number, the client will refresh connections at random
587 * moments not more apart from each other than this duration. This is
588 * necessary to avoid all connections simultaneously expiring and causing
589 * latency spikes.
590 *
591 * If needed it changes max_conn_refresh_period() to preserve the invariant:
592 *
593 * @code
594 * assert(min_conn_refresh_period() <= max_conn_refresh_period())
595 * @endcode
596 *
597 * @deprecated Please configure `google::cloud::Options` with
598 * `bigtable::MinConnectionRefreshOption` and
599 * `bigtable::MaxConnectionRefreshOption` instead.
600 */
601 GOOGLE_CLOUD_CPP_DEPRECATED(
602 "use `google::cloud::Options` with `MinConnectionRefreshOption` and "
603 "`MaxConnectionRefreshOption` instead")
604 ClientOptions& set_max_conn_refresh_period(std::chrono::milliseconds period) {
606 auto& min_conn_refresh_period = opts_.lookup<MinConnectionRefreshOption>();
607 min_conn_refresh_period = (std::min)(min_conn_refresh_period, period);
608 return *this;
609 }
610
611 /**
612 * Minimum connection refresh period, as set via `set_min_conn_refresh_period`
613 *
614 * @deprecated Please configure `google::cloud::Options` with
615 * `bigtable::MinConnectionRefreshOption` and
616 * `bigtable::MaxConnectionRefreshOption` instead.
617 */
618 GOOGLE_CLOUD_CPP_DEPRECATED(
619 "use `google::cloud::Options` with `MinConnectionRefreshOption` and "
620 "`MaxConnectionRefreshOption` instead")
621 std::chrono::milliseconds min_conn_refresh_period() {
623 }
624
625 /**
626 * Configures the *minimum* connection refresh period. The library will wait
627 * at least this long before attempting any refresh operation.
628 *
629 * If needed it changes max_conn_refresh_period() to preserve the invariant:
630 *
631 * @code
632 * assert(min_conn_refresh_period() <= max_conn_refresh_period())
633 * @endcode
634 *
635 * @deprecated Please configure `google::cloud::Options` with
636 * `bigtable::MinConnectionRefreshOption` and
637 * `bigtable::MaxConnectionRefreshOption` instead.
638 */
639 GOOGLE_CLOUD_CPP_DEPRECATED(
640 "use `google::cloud::Options` with `MinConnectionRefreshOption` and "
641 "`MaxConnectionRefreshOption` instead")
642 ClientOptions& set_min_conn_refresh_period(std::chrono::milliseconds period) {
644 auto& max_conn_refresh_period = opts_.lookup<MaxConnectionRefreshOption>();
645 max_conn_refresh_period = (std::max)(max_conn_refresh_period, period);
646 return *this;
647 }
648
649 /**
650 * Set the number of background threads.
651 *
652 * @note This value is not used if `DisableBackgroundThreads()` is called.
653 *
654 * @deprecated Please configure `google::cloud::Options` with
655 * `google::cloud::GrpcBackgroundThreadPoolSizeOption` instead.
656 */
657 GOOGLE_CLOUD_CPP_DEPRECATED(
658 "use `google::cloud::Options` with "
659 "`google::cloud::GrpcBackgroundThreadPoolSizeOption` instead")
662 return *this;
663 }
664
665 /**
666 * Return the number of background threads.
667 *
668 * @note This value is not used if `DisableBackgroundThreads()` is called.
669 *
670 * @deprecated Please configure `google::cloud::Options` with
671 * `google::cloud::GrpcBackgroundThreadPoolSizeOption` instead.
672 */
673 GOOGLE_CLOUD_CPP_DEPRECATED(
674 "use `google::cloud::Options` with "
675 "`google::cloud::GrpcBackgroundThreadPoolSizeOption` instead")
676 std::size_t background_thread_pool_size() const {
678 }
679
680 /**
681 * Configure the connection to use @p cq for all background work.
682 *
683 * Connections need to perform background work on behalf of the application.
684 * Normally they just create a background thread and a `CompletionQueue` for
685 * this work, but the application may need more fine-grained control of their
686 * threads. In this case the application can provide the `CompletionQueue` and
687 * it assumes responsibility for creating one or more threads blocked on
688 * `CompletionQueue::Run()`.
689 *
690 * @deprecated Please configure `google::cloud::Options` with
691 * `google::cloud::GrpcCompletionQueueOption` instead.
692 */
693 GOOGLE_CLOUD_CPP_DEPRECATED(
694 "use `google::cloud::Options` with "
695 "`google::cloud::GrpcCompletionQueueOption` instead")
697 google::cloud::CompletionQueue const& cq);
698
699 /**
700 * Backwards compatibility alias
701 *
702 * @deprecated Consider using `google::cloud::BackgroundThreadsFactory`
703 * directly
704 */
705 using BackgroundThreadsFactory = ::google::cloud::BackgroundThreadsFactory;
706
707 /// @deprecated Not intended for applications to use. There is no alternative
708 /// implemented or planned.
709 GOOGLE_CLOUD_CPP_DEPRECATED(
710 "Not intended for applications to use. There is no alternative "
711 "implemented or planned")
712 BackgroundThreadsFactory background_threads_factory() const;
713
714 private:
715 friend struct ClientOptionsTestTraits;
716 friend Options&& internal::MakeOptions(ClientOptions&&);
717
718 /// Return the current endpoint for instance admin RPCs.
719 std::string const& instance_admin_endpoint() const {
721 }
722
723 std::string connection_pool_name_;
724 Options opts_;
725};
726
727GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
728} // namespace bigtable
729} // namespace cloud
730} // namespace google
731
732#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_CLIENT_OPTIONS_H
ValueTypeT< T > const & get() const
ValueTypeT< T > & lookup(ValueTypeT< T > value={})
Options & set(ValueTypeT< T > v)
Status(StatusCode code, std::string message, ErrorInfo info={})
Configuration options for the Bigtable Client.
Definition: client_options.h:55
static std::string UserAgentPrefix()
Return the user agent prefix used by the library.
ClientOptions & set_admin_endpoint(std::string endpoint)
Set the current endpoint for admin RPCs.
Definition: client_options.h:172
std::chrono::milliseconds max_conn_refresh_period()
Maximum connection refresh period, as set via set_max_conn_refresh_period
Definition: client_options.h:581
TracingOptions const & tracing_options() const
Return the options for use when tracing RPCs.
Definition: client_options.h:567
ClientOptions & set_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 fro...
Definition: client_options.h:604
ClientOptions & disable_tracing(std::string const &component)
Disable tracing for component in clients configured with this object.
Definition: client_options.h:553
void SetMaxReceiveMessageSize(int size)
Set the max receive message size in bytes.
Definition: client_options.h:430
void SetResourceQuota(grpc::ResourceQuota const &resource_quota)
Set the buffer pool to be attached to the constructed channel.
Definition: client_options.h:411
ClientOptions & set_channel_arguments(grpc::ChannelArguments const &channel_arguments)
Set all the channel arguments.
Definition: client_options.h:298
ClientOptions()
Initialize the client options.
std::shared_ptr< grpc::ChannelCredentials > credentials() const
Return the current credentials.
Definition: client_options.h:255
void SetCompressionAlgorithm(grpc_compression_algorithm algorithm)
Set compression algorithm for channel.
Definition: client_options.h:317
ClientOptions & DisableBackgroundThreads(google::cloud::CompletionQueue const &cq)
Configure the connection to use cq for all background work.
grpc::ChannelArguments channel_arguments() const
Access all the channel arguments.
Definition: client_options.h:285
std::size_t connection_pool_size() const
Return the size of the connection pool.
Definition: client_options.h:242
bool tracing_enabled(std::string const &component) const
Return whether tracing is enabled for the given component.
Definition: client_options.h:525
ClientOptions(std::shared_ptr< grpc::ChannelCredentials > creds)
Connect to the production instance of Cloud Bigtable using creds.
ClientOptions & set_connection_pool_name(std::string name)
Set the name of the connection pool.
Definition: client_options.h:199
std::chrono::milliseconds min_conn_refresh_period()
Minimum connection refresh period, as set via set_min_conn_refresh_period
Definition: client_options.h:621
void SetMaxSendMessageSize(int size)
Set the max send message size in bytes.
Definition: client_options.h:448
std::string const & data_endpoint() const
Return the current endpoint for data RPCs.
Definition: client_options.h:132
ClientOptions & set_min_conn_refresh_period(std::chrono::milliseconds period)
Configures the minimum connection refresh period.
Definition: client_options.h:642
BackgroundThreadsFactory background_threads_factory() const
std::string const & admin_endpoint() const
Return the current endpoint for admin RPCs.
Definition: client_options.h:159
void SetSslTargetNameOverride(grpc::string const &name)
Set target name override for SSL host name checking.
Definition: client_options.h:503
ClientOptions(Options opts)
Initialize the client options.
std::size_t background_thread_pool_size() const
Return the number of background threads.
Definition: client_options.h:676
ClientOptions & set_background_thread_pool_size(std::size_t s)
Set the number of background threads.
Definition: client_options.h:660
void SetLoadBalancingPolicyName(grpc::string const &lb_policy_name)
Set LB policy name.
Definition: client_options.h:467
void SetServiceConfigJSON(grpc::string const &service_config_json)
Set service config in JSON form.
Definition: client_options.h:485
ClientOptions & set_data_endpoint(std::string endpoint)
Set the current endpoint for data RPCs.
Definition: client_options.h:145
ClientOptions & enable_tracing(std::string const &component)
Enable tracing for component in clients configured with this object.
Definition: client_options.h:539
std::string const & connection_pool_name() const
Return the name of the connection pool.
Definition: client_options.h:215
void SetUserAgentPrefix(grpc::string const &user_agent_prefix)
Set the string to prepend to the user agent.
Definition: client_options.h:393
ClientOptions & set_connection_pool_size(std::size_t size)
Set the size of the connection pool.
google::cloud::Status SetGrpclbFallbackTimeout(std::chrono::duration< Rep, Period > fallback_timeout)
Set the grpclb fallback timeout with the timestamp fallback_timeout for the channel.
Definition: client_options.h:362
ClientOptions & SetCredentials(std::shared_ptr< grpc::ChannelCredentials > credentials)
Set the current credentials.
Definition: client_options.h:268
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28
The endpoint for table admin operations.
Definition: options.h:93
The endpoint for data operations.
Definition: options.h:84
The endpoint for instance admin operations.
Definition: options.h:106
Maximum time in ms to refresh connections.
Definition: options.h:133
Minimum time in ms to refresh connections.
Definition: options.h:117