From d6d86fe2049590f0bb7025e1e406a92d37e23b84 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Fri, 19 Dec 2025 03:46:58 +0000 Subject: [PATCH 1/5] impl(bigtable): remove deprecated client options --- doc/v3-migration-guide.md | 47 ++ google/cloud/bigtable/client_options.h | 672 ------------------------- 2 files changed, 47 insertions(+), 672 deletions(-) diff --git a/doc/v3-migration-guide.md b/doc/v3-migration-guide.md index 9ac6298d27609..16b9928488452 100644 --- a/doc/v3-migration-guide.md +++ b/doc/v3-migration-guide.md @@ -46,6 +46,53 @@ module which can be added to your `MODULE.bazel` file as a dependency. ### Bigtable +#### `bigtable::ClientOptions` + +The deprecated `bigtable::ClientOptions` has been removed. Please use +`google::cloud::Options` instead. + +The following table shows the mapping from `bigtable::ClientOptions` methods to +their `google::cloud::Options` equivalents: + +| `bigtable::ClientOptions` method | `google::cloud::Options` equivalent | +| ----------------------------------------------- | ------------------------------------------------------------------------------------------------ | +| `(constructor)` | `google::cloud::Options{}` | +| `set_data_endpoint` |`google::cloud::EndpointOption` | +| `set_admin_endpoint` |`google::cloud::EndpointOption` | +| `set_connection_pool_name` | `google::cloud::GrpcChannelArgumentsOption` or`google::cloud::GrpcChannelArgumentsNativeOption` | +| `set_connection_pool_size` |`google::cloud::GrpcNumChannelsOption` | +| `SetCredentials` |`google::cloud::GrpcCredentialOption` | +| `set_channel_arguments` |`google::cloud::GrpcChannelArgumentsNativeOption`| +| `SetCompressionAlgorithm` |`google::cloud::GrpcChannelArgumentsNativeOption`| +| `SetGrpclbFallbackTimeout` |`google::cloud::GrpcChannelArgumentsNativeOption`| +| `SetUserAgentPrefix` | `google::cloud::UserAgentProductsOption` or`google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetResourceQuota` |`google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetMaxReceiveMessageSize` |`google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetMaxSendMessageSize` |`google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetLoadBalancingPolicyName` |`google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetServiceConfigJSON` |`google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetSslTargetNameOverride` |`google::cloud::GrpcChannelArgumentsNativeOption` | +| `enable_tracing`, `disable_tracing` |`google::cloud::LoggingComponentsOption` | +| `tracing_options` |`google::cloud::GrpcTracingOptionsOption` | +| `set_max_conn_refresh_period` |`bigtable::MaxConnectionRefreshOption` | +| `set_min_conn_refresh_period` |`bigtable::MinConnectionRefreshOption` | +| `set_background_thread_pool_size` |`google::cloud::GrpcBackgroundThreadPoolSizeOption` | +| `DisableBackgroundThreads` |`google::cloud::GrpcCompletionQueueOption` | + +Example usage of the replacements can be found below. + +**Before:** +```cpp +auto client = bigtable::Client( + bigtable::ClientOptions().set_connection_pool_size(4)); +``` + +**After:** +```cpp +auto client = bigtable::Client( + google::cloud::Options{}.set(4)); +``` + ### Pubsub ### Spanner diff --git a/google/cloud/bigtable/client_options.h b/google/cloud/bigtable/client_options.h index 834ea1a162e53..c785ba10026ef 100644 --- a/google/cloud/bigtable/client_options.h +++ b/google/cloud/bigtable/client_options.h @@ -53,678 +53,6 @@ Options&& MakeOptions(ClientOptions&& o); * * @deprecated Please use `google::cloud::Options` instead. */ -class ClientOptions { - public: - /** - * Initialize the client options. - * - * Configure the client to connect to the Cloud Bigtable service, using the - * default options. - * - * @par 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 The Google Cloud Platform introduction to - * [application default - * credentials](https://cloud.google.com/docs/authentication/production) - * @see `grpc::GoogleDefaultCredentials` in the [grpc - * documentation](https://grpc.io/grpc/cpp/namespacegrpc.html) - * @see The [documentation](https://cloud.google.com/bigtable/docs/emulator) - * for the Cloud Bigtable Emulator. - * - * @deprecated Please use `google::cloud::Options` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED("use `google::cloud::Options` instead") - ClientOptions(); - - /** - * Initialize the client options. - * - * Expected options are any of the types in the following option lists. - * - * - `google::cloud::CommonOptionList` - * - `google::cloud::GrpcOptionList` - * - `google::cloud::bigtable::ClientOptionList` - * - * @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. - * - * @param opts (optional) configuration options - * - * @deprecated Please use `google::cloud::Options` directly instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED("use `google::cloud::Options` directly instead") - explicit ClientOptions(Options opts); - - /** - * Connect to the production instance of Cloud Bigtable using @p 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. - * - * @param creds gRPC authentication credentials - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcCredentialOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with `google::cloud::GrpcCredentialOption` " - "instead") - explicit ClientOptions(std::shared_ptr creds); - - /** - * Return the current endpoint for data RPCs. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::EndpointOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with `google::cloud::EndpointOption` " - "instead") - std::string const& data_endpoint() const { - return opts_.get(); - } - - /** - * Set the current endpoint for data RPCs. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::EndpointOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with `google::cloud::EndpointOption` " - "instead") - ClientOptions& set_data_endpoint(std::string endpoint) { - opts_.set(std::move(endpoint)); - return *this; - } - - /** - * Return the current endpoint for admin RPCs. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::EndpointOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with `google::cloud::EndpointOption` " - "instead") - std::string const& admin_endpoint() const { - return opts_.get(); - } - - /** - * Set the current endpoint for admin RPCs. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::EndpointOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with `google::cloud::EndpointOption` " - "instead") - ClientOptions& set_admin_endpoint(std::string endpoint) { - opts_.set(endpoint); - // These two endpoints are generally equivalent, but they may differ in - // some tests. - opts_.set(std::move(endpoint)); - return *this; - } - - /** - * 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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsOption` or - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsOption` or " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - ClientOptions& set_connection_pool_name(std::string name) { - connection_pool_name_ = std::move(name); - return *this; - } - - /** - * Return the name of the connection pool. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsOption` or - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsOption` or " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - std::string const& connection_pool_name() const { - return connection_pool_name_; - } - - /** - * Set the size of the connection pool. - * - * Specifying 0 for @p size will set the size of the connection pool to - * default. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcNumChannelsOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcNumChannelsOption` instead") - ClientOptions& set_connection_pool_size(std::size_t size); - - /** - * Return the size of the connection pool. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcNumChannelsOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcNumChannelsOption` instead") - std::size_t connection_pool_size() const { - return opts_.get(); - } - - /** - * Return the current credentials. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcCredentialOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcCredentialOption` instead") - std::shared_ptr credentials() const { - return opts_.get(); - } - - /** - * Set the current credentials. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcCredentialOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcCredentialOption` instead") - ClientOptions& SetCredentials( - std::shared_ptr credentials) { - opts_.set(std::move(credentials)); - return *this; - } - - /** - * Access all the channel arguments. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsOption` or - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsOption` or " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - grpc::ChannelArguments channel_arguments() const { - return ::google::cloud::internal::MakeChannelArguments(opts_); - } - - /** - * Set all the channel arguments. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - ClientOptions& set_channel_arguments( - grpc::ChannelArguments const& channel_arguments) { - opts_.set(channel_arguments); - return *this; - } - - /** - * 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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - void SetCompressionAlgorithm(grpc_compression_algorithm algorithm) { - opts_.lookup().SetCompressionAlgorithm( - algorithm); - } - - /** - * Set the `grpclb` fallback timeout with the timestamp @p fallback_timeout - * for the channel. - * - * For example: - * - * @code - * bigtable::ClientOptions::SetGrpclbFallbackTimeout( - * std::chrono::milliseconds(5000)) - * bigtable::ClientOptions::SetGrpclbFallbackTimeout( - * std::chrono::seconds(5)) - * @endcode - * - * @tparam Rep a placeholder to match the Rep tparam for @p 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. - * @tparam Period a placeholder to match the Period tparam for @p - * 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 - * [std::chrono::duration<>](http://en.cppreference.com/w/cpp/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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - template - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - google::cloud::Status SetGrpclbFallbackTimeout( - std::chrono::duration fallback_timeout) { - std::chrono::milliseconds ft_ms = - std::chrono::duration_cast(fallback_timeout); - - if (ft_ms.count() > std::numeric_limits::max()) { - return google::cloud::internal::OutOfRangeError( - "The supplied duration is larger than the " - "maximum value allowed by gRPC (INT_MAX)", - GCP_ERROR_INFO()); - } - auto fallback_timeout_ms = static_cast(ft_ms.count()); - opts_.lookup().SetGrpclbFallbackTimeout( - fallback_timeout_ms); - return google::cloud::Status(); - } - - /** - * 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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::UserAgentProductsOption` or - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::UserAgentProductsOption` " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - void SetUserAgentPrefix(grpc::string const& user_agent_prefix) { - opts_.lookup().SetUserAgentPrefix( - user_agent_prefix); - } - - /** - * 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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - void SetResourceQuota(grpc::ResourceQuota const& resource_quota) { - opts_.lookup().SetResourceQuota( - resource_quota); - } - - /** - * 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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - void SetMaxReceiveMessageSize(int size) { - opts_.lookup().SetMaxReceiveMessageSize( - size); - } - - /** - * 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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - void SetMaxSendMessageSize(int size) { - opts_.lookup().SetMaxSendMessageSize( - size); - } - - /** - * 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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - void SetLoadBalancingPolicyName(grpc::string const& lb_policy_name) { - opts_.lookup().SetLoadBalancingPolicyName( - lb_policy_name); - } - - /** - * 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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - void SetServiceConfigJSON(grpc::string const& service_config_json) { - opts_.lookup().SetServiceConfigJSON( - service_config_json); - } - - /** - * 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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcChannelArgumentsNativeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcChannelArgumentsNativeOption` instead") - void SetSslTargetNameOverride(grpc::string const& name) { - opts_.lookup().SetSslTargetNameOverride( - name); - } - - /// Return the user agent prefix used by the library. - GOOGLE_CLOUD_CPP_DEPRECATED("Not intended for use in application code") - static std::string UserAgentPrefix(); - - /** - * Return whether tracing is enabled for the given @p 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. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::LoggingComponentsOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::LoggingComponentsOption` instead") - bool tracing_enabled(std::string const& component) const { - return google::cloud::internal::Contains( - opts_.get(), component); - } - - /** - * Enable tracing for @p component in clients configured with this object. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::LoggingComponentsOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::LoggingComponentsOption` instead") - ClientOptions& enable_tracing(std::string const& component) { - opts_.lookup().insert(component); - return *this; - } - - /** - * Disable tracing for @p component in clients configured with this object. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::LoggingComponentsOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::LoggingComponentsOption` instead") - ClientOptions& disable_tracing(std::string const& component) { - opts_.lookup().erase(component); - return *this; - } - - /** - * Return the options for use when tracing RPCs. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcTracingOptionsOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcTracingOptionsOption` instead") - TracingOptions const& tracing_options() const { - return opts_.get(); - } - - /** - * Maximum connection refresh period, as set via `set_max_conn_refresh_period` - * - * @deprecated Please configure `google::cloud::Options` with - * `bigtable::MinConnectionRefreshOption` and - * `bigtable::MaxConnectionRefreshOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with `MinConnectionRefreshOption` and " - "`MaxConnectionRefreshOption` instead") - std::chrono::milliseconds max_conn_refresh_period() { - return opts_.get(); - } - - /** - * 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: - * - * @code - * assert(min_conn_refresh_period() <= max_conn_refresh_period()) - * @endcode - * - * @deprecated Please configure `google::cloud::Options` with - * `bigtable::MinConnectionRefreshOption` and - * `bigtable::MaxConnectionRefreshOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with `MinConnectionRefreshOption` and " - "`MaxConnectionRefreshOption` instead") - ClientOptions& set_max_conn_refresh_period(std::chrono::milliseconds period) { - opts_.set(period); - auto& min_conn_refresh_period = opts_.lookup(); - min_conn_refresh_period = (std::min)(min_conn_refresh_period, period); - return *this; - } - - /** - * Minimum connection refresh period, as set via `set_min_conn_refresh_period` - * - * @deprecated Please configure `google::cloud::Options` with - * `bigtable::MinConnectionRefreshOption` and - * `bigtable::MaxConnectionRefreshOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with `MinConnectionRefreshOption` and " - "`MaxConnectionRefreshOption` instead") - std::chrono::milliseconds min_conn_refresh_period() { - return opts_.get(); - } - - /** - * 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: - * - * @code - * assert(min_conn_refresh_period() <= max_conn_refresh_period()) - * @endcode - * - * @deprecated Please configure `google::cloud::Options` with - * `bigtable::MinConnectionRefreshOption` and - * `bigtable::MaxConnectionRefreshOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with `MinConnectionRefreshOption` and " - "`MaxConnectionRefreshOption` instead") - ClientOptions& set_min_conn_refresh_period(std::chrono::milliseconds period) { - opts_.set(period); - auto& max_conn_refresh_period = opts_.lookup(); - max_conn_refresh_period = (std::max)(max_conn_refresh_period, period); - return *this; - } - - /** - * Set the number of background threads. - * - * @note This value is not used if `DisableBackgroundThreads()` is called. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcBackgroundThreadPoolSizeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcBackgroundThreadPoolSizeOption` instead") - ClientOptions& set_background_thread_pool_size(std::size_t s) { - opts_.set(s); - return *this; - } - - /** - * Return the number of background threads. - * - * @note This value is not used if `DisableBackgroundThreads()` is called. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcBackgroundThreadPoolSizeOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcBackgroundThreadPoolSizeOption` instead") - std::size_t background_thread_pool_size() const { - return opts_.get(); - } - - /** - * Configure the connection to use @p 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()`. - * - * @deprecated Please configure `google::cloud::Options` with - * `google::cloud::GrpcCompletionQueueOption` instead. - */ - GOOGLE_CLOUD_CPP_DEPRECATED( - "use `google::cloud::Options` with " - "`google::cloud::GrpcCompletionQueueOption` instead") - ClientOptions& DisableBackgroundThreads( - google::cloud::CompletionQueue const& cq); - - /** - * Backwards compatibility alias - * - * @deprecated Consider using `google::cloud::BackgroundThreadsFactory` - * directly - */ - using BackgroundThreadsFactory = ::google::cloud::BackgroundThreadsFactory; - - /// @deprecated Not intended for applications to use. There is no alternative - /// implemented or planned. - GOOGLE_CLOUD_CPP_DEPRECATED( - "Not intended for applications to use. There is no alternative " - "implemented or planned") - BackgroundThreadsFactory background_threads_factory() const; - - private: - friend struct ClientOptionsTestTraits; - friend Options&& internal::MakeOptions(ClientOptions&&); - - /// Return the current endpoint for instance admin RPCs. - std::string const& instance_admin_endpoint() const { - return opts_.get(); - } - - std::string connection_pool_name_; - Options opts_; -}; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable From ff0b1803f8e1aef2546816e62acc427c84aae27d Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Sat, 20 Dec 2025 01:42:40 +0000 Subject: [PATCH 2/5] impl(bigtable): remove deprecated ClientOptions --- doc/v3-migration-guide.md | 54 ++ google/cloud/bigtable/CMakeLists.txt | 3 - google/cloud/bigtable/admin_client.cc | 6 - google/cloud/bigtable/admin_client.h | 12 +- google/cloud/bigtable/admin_client_test.cc | 10 - .../bigtable/bigtable_client_unit_tests.bzl | 1 - google/cloud/bigtable/client_options.cc | 83 --- google/cloud/bigtable/client_options.h | 62 -- google/cloud/bigtable/client_options_test.cc | 593 ------------------ google/cloud/bigtable/data_client.cc | 7 - google/cloud/bigtable/data_client.h | 14 +- google/cloud/bigtable/data_client_test.cc | 26 - google/cloud/bigtable/data_connection.h | 1 - .../bigtable_instance_admin_snippets.cc | 1 + .../bigtable/google_cloud_cpp_bigtable.bzl | 2 - .../cloud/bigtable/instance_admin_client.cc | 6 - google/cloud/bigtable/instance_admin_client.h | 11 - .../bigtable/instance_admin_client_test.cc | 10 - google/cloud/bigtable/instance_admin_test.cc | 1 + google/cloud/bigtable/internal/bulk_mutator.h | 3 +- .../bigtable/mocks/mock_data_connection.h | 1 + google/cloud/bigtable/mutation_batcher.h | 1 - google/cloud/bigtable/table.h | 1 + .../cloud/bigtable/testing/mock_data_client.h | 4 - .../bigtable/tests/data_integration_test.cc | 1 + .../tests/instance_admin_integration_test.cc | 1 + .../table_sample_rows_integration_test.cc | 1 - 27 files changed, 65 insertions(+), 851 deletions(-) delete mode 100644 google/cloud/bigtable/client_options.cc delete mode 100644 google/cloud/bigtable/client_options.h delete mode 100644 google/cloud/bigtable/client_options_test.cc diff --git a/doc/v3-migration-guide.md b/doc/v3-migration-guide.md index 16b9928488452..38f7d9dbdc6f7 100644 --- a/doc/v3-migration-guide.md +++ b/doc/v3-migration-guide.md @@ -93,6 +93,60 @@ auto client = bigtable::Client( google::cloud::Options{}.set(4)); ``` +#### `bigtable::CreateDefaultDataClient` + +The deprecated `bigtable::CreateDefaultDataClient` function has been removed. +Please use `bigtable::MakeDataClient` instead. + +**Before:** +```cpp +auto client = bigtable::CreateDefaultDataClient( + "my-project", "my-instance", + bigtable::ClientOptions().set_connection_pool_size(4)); +``` + +**After:** +```cpp +auto client = bigtable::MakeDataClient( + "my-project", "my-instance", + google::cloud::Options{}.set(4)); +``` + +#### `bigtable::CreateDefaultAdminClient` + +The deprecated `bigtable::CreateDefaultAdminClient` function has been removed. +Please use `bigtable::MakeAdminClient` instead. + +**Before:** +```cpp +auto client = bigtable::CreateDefaultAdminClient( + "my-project", bigtable::ClientOptions().set_connection_pool_size(4)); +``` + +**After:** +```cpp +auto client = bigtable::MakeAdminClient( + "my-project", + google::cloud::Options{}.set(4)); +``` + +#### `bigtable::CreateDefaultInstanceAdminClient` + +The deprecated `bigtable::CreateDefaultInstanceAdminClient` function has been +removed. Please use `bigtable::MakeInstanceAdminClient` instead. + +**Before:** +```cpp +auto client = bigtable::CreateDefaultInstanceAdminClient( + "my-project", bigtable::ClientOptions().set_connection_pool_size(4)); +``` + +**After:** +```cpp +auto client = bigtable::MakeInstanceAdminClient( + "my-project", + google::cloud::Options{}.set(4)); +``` ### Pubsub ### Spanner diff --git a/google/cloud/bigtable/CMakeLists.txt b/google/cloud/bigtable/CMakeLists.txt index 7b751b0ba1bb5..e07ca6244691f 100644 --- a/google/cloud/bigtable/CMakeLists.txt +++ b/google/cloud/bigtable/CMakeLists.txt @@ -116,8 +116,6 @@ add_library( cell.h client.cc client.h - client_options.cc - client_options.h cluster_config.cc cluster_config.h cluster_list_responses.h @@ -452,7 +450,6 @@ if (BUILD_TESTING) bound_query_test.cc bytes_test.cc cell_test.cc - client_options_test.cc client_test.cc cluster_config_test.cc column_family_test.cc diff --git a/google/cloud/bigtable/admin_client.cc b/google/cloud/bigtable/admin_client.cc index cdc151945d6d7..4bcf80c036e36 100644 --- a/google/cloud/bigtable/admin_client.cc +++ b/google/cloud/bigtable/admin_client.cc @@ -28,12 +28,6 @@ std::shared_ptr MakeAdminClient(std::string project, new AdminClient(std::move(project), std::move(params))); } -std::shared_ptr CreateDefaultAdminClient(std::string project, - ClientOptions options) { - return MakeAdminClient(std::move(project), - internal::MakeOptions(std::move(options))); -} - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable } // namespace cloud diff --git a/google/cloud/bigtable/admin_client.h b/google/cloud/bigtable/admin_client.h index 31ebc18855d7b..9f8dd1b5b9aab 100644 --- a/google/cloud/bigtable/admin_client.h +++ b/google/cloud/bigtable/admin_client.h @@ -16,9 +16,9 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_ADMIN_CLIENT_H #include "google/cloud/bigtable/admin/bigtable_table_admin_connection.h" -#include "google/cloud/bigtable/client_options.h" #include "google/cloud/bigtable/internal/admin_client_params.h" #include "google/cloud/bigtable/version.h" +#include "google/cloud/grpc_options.h" #include "google/cloud/options.h" #include #include @@ -65,16 +65,6 @@ class AdminClient final { std::shared_ptr MakeAdminClient(std::string project, Options options = {}); -/** - * Create a new table admin client configured via @p options. - * - * @deprecated use the `MakeAdminClient` method which accepts - * `google::cloud::Options` instead. - */ -GOOGLE_CLOUD_CPP_DEPRECATED("use `MakeAdminClient` instead") -std::shared_ptr CreateDefaultAdminClient(std::string project, - ClientOptions options); - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable } // namespace cloud diff --git a/google/cloud/bigtable/admin_client_test.cc b/google/cloud/bigtable/admin_client_test.cc index f9f0ccc617eb5..d723f8a64ff1b 100644 --- a/google/cloud/bigtable/admin_client_test.cc +++ b/google/cloud/bigtable/admin_client_test.cc @@ -21,16 +21,6 @@ namespace bigtable { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { -#include "google/cloud/internal/disable_deprecation_warnings.inc" - -TEST(AdminClientTest, CreateDefaultClient) { - auto admin_client = CreateDefaultAdminClient("test-project", {}); - ASSERT_TRUE(admin_client); - EXPECT_EQ("test-project", admin_client->project()); -} - -#include "google/cloud/internal/diagnostics_pop.inc" - TEST(AdminClientTest, MakeClient) { auto admin_client = MakeAdminClient("test-project"); ASSERT_TRUE(admin_client); diff --git a/google/cloud/bigtable/bigtable_client_unit_tests.bzl b/google/cloud/bigtable/bigtable_client_unit_tests.bzl index c5dda043da0a4..66ec4af50c0d2 100644 --- a/google/cloud/bigtable/bigtable_client_unit_tests.bzl +++ b/google/cloud/bigtable/bigtable_client_unit_tests.bzl @@ -24,7 +24,6 @@ bigtable_client_unit_tests = [ "bound_query_test.cc", "bytes_test.cc", "cell_test.cc", - "client_options_test.cc", "client_test.cc", "cluster_config_test.cc", "column_family_test.cc", diff --git a/google/cloud/bigtable/client_options.cc b/google/cloud/bigtable/client_options.cc deleted file mode 100644 index 7bee3a22e4675..0000000000000 --- a/google/cloud/bigtable/client_options.cc +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2017 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and - -#include "google/cloud/bigtable/client_options.h" -#include "google/cloud/bigtable/internal/client_options_defaults.h" -#include "google/cloud/bigtable/internal/defaults.h" -#include "google/cloud/internal/background_threads_impl.h" -#include "google/cloud/internal/getenv.h" -#include "google/cloud/internal/user_agent_prefix.h" -#include "absl/strings/str_split.h" -#include -#include - -namespace google { -namespace cloud { -namespace bigtable { -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -namespace internal { -Options&& MakeOptions(ClientOptions&& o) { - if (!o.connection_pool_name_.empty()) { - o.opts_ - .lookup()["cbt-c++/connection-pool-name"] = - std::move(o.connection_pool_name_); - } - return std::move(o.opts_); -} -} // namespace internal - -ClientOptions::ClientOptions() { opts_ = internal::DefaultOptions(); } - -ClientOptions::ClientOptions(Options opts) { - ::google::cloud::internal::CheckExpectedOptions< - ClientOptionList, CommonOptionList, GrpcOptionList>(opts, __func__); - opts_ = internal::DefaultOptions(std::move(opts)); -} - -ClientOptions::ClientOptions(std::shared_ptr creds) { - opts_ = internal::DefaultOptions( - Options{}.set(std::move(creds))); - - // This constructor ignores the emulator environment variables, which might be - // set by `internal::DefaultOptions()`. - opts_.set("bigtable.googleapis.com"); - opts_.set("bigtableadmin.googleapis.com"); - opts_.set("bigtableadmin.googleapis.com"); -} - -// NOLINTNEXTLINE(readability-identifier-naming) -ClientOptions& ClientOptions::set_connection_pool_size(std::size_t size) { - opts_.set(size == 0 - ? internal::DefaultConnectionPoolSize() - : static_cast(size)); - return *this; -} - -std::string ClientOptions::UserAgentPrefix() { - return google::cloud::internal::UserAgentPrefix(); -} - -ClientOptions& ClientOptions::DisableBackgroundThreads( - google::cloud::CompletionQueue const& cq) { - opts_.set(cq); - return *this; -} - -BackgroundThreadsFactory ClientOptions::background_threads_factory() const { - return google::cloud::internal::MakeBackgroundThreadsFactory(opts_); -} - -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace bigtable -} // namespace cloud -} // namespace google diff --git a/google/cloud/bigtable/client_options.h b/google/cloud/bigtable/client_options.h deleted file mode 100644 index c785ba10026ef..0000000000000 --- a/google/cloud/bigtable/client_options.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2017 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_CLIENT_OPTIONS_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_CLIENT_OPTIONS_H - -#include "google/cloud/bigtable/options.h" -#include "google/cloud/bigtable/version.h" -#include "google/cloud/background_threads.h" -#include "google/cloud/common_options.h" -#include "google/cloud/completion_queue.h" -#include "google/cloud/grpc_options.h" -#include "google/cloud/internal/algorithm.h" -#include "google/cloud/internal/make_status.h" -#include "google/cloud/options.h" -#include "google/cloud/status.h" -#include "google/cloud/tracing_options.h" -#include "absl/strings/str_split.h" -#include -#include -#include -#include -#include - -namespace google { -namespace cloud { -namespace bigtable { -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -class ClientOptions; -namespace internal { -Options&& MakeOptions(ClientOptions&& o); -} // namespace internal - -/** - * Configuration options for the Bigtable Client. - * - * Applications typically configure the client class using: - * @code - * auto client = - * bigtable::Client(bigtable::ClientOptions().SetCredentials(...)); - * @endcode - * - * @deprecated Please use `google::cloud::Options` instead. - */ - -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace bigtable -} // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_CLIENT_OPTIONS_H diff --git a/google/cloud/bigtable/client_options_test.cc b/google/cloud/bigtable/client_options_test.cc deleted file mode 100644 index 80594490cc89d..0000000000000 --- a/google/cloud/bigtable/client_options_test.cc +++ /dev/null @@ -1,593 +0,0 @@ -// Copyright 2017 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "google/cloud/bigtable/client_options.h" -#include "google/cloud/bigtable/internal/client_options_defaults.h" -#include "google/cloud/bigtable/options.h" -#include "google/cloud/grpc_options.h" -#include "google/cloud/internal/background_threads_impl.h" -#include "google/cloud/status.h" -#include "google/cloud/testing_util/scoped_environment.h" -#include "google/cloud/testing_util/status_matchers.h" -#include "absl/types/optional.h" -#include -#include -// ClientOptions is deprecated. We need to suppress the compiler warnings. -#include "google/cloud/internal/disable_deprecation_warnings.inc" - -namespace google { -namespace cloud { -namespace bigtable { -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -struct ClientOptionsTestTraits { - static std::string const& InstanceAdminEndpoint( - ClientOptions const& options) { - return options.instance_admin_endpoint(); - } -}; -namespace { -using ::google::cloud::internal::GetIntChannelArgument; -using ::google::cloud::internal::GetStringChannelArgument; -using ::google::cloud::testing_util::ScopedEnvironment; -using ::testing::HasSubstr; - -TEST(ClientOptionsTest, ClientOptionsDefaultSettings) { - ClientOptions client_options; - EXPECT_EQ("bigtable.googleapis.com", client_options.data_endpoint()); - EXPECT_EQ("bigtableadmin.googleapis.com", client_options.admin_endpoint()); - EXPECT_EQ(typeid(grpc::GoogleDefaultCredentials()), - typeid(client_options.credentials())); - - EXPECT_EQ("", client_options.connection_pool_name()); - // The number of connections should be >= 1, we "know" what the actual value - // is, but we do not want a change-detection-test. - EXPECT_LE(1UL, client_options.connection_pool_size()); - - auto args = client_options.channel_arguments(); - auto max_send = GetIntChannelArgument(args, GRPC_ARG_MAX_SEND_MESSAGE_LENGTH); - ASSERT_TRUE(max_send.has_value()); - EXPECT_EQ(BIGTABLE_CLIENT_DEFAULT_MAX_MESSAGE_LENGTH, max_send.value()); - auto max_recv = - GetIntChannelArgument(args, GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH); - ASSERT_TRUE(max_recv.has_value()); - EXPECT_EQ(BIGTABLE_CLIENT_DEFAULT_MAX_MESSAGE_LENGTH, max_recv.value()); - - // See `kDefaultKeepaliveTime` - auto time = GetIntChannelArgument(args, GRPC_ARG_KEEPALIVE_TIME_MS); - ASSERT_TRUE(time.has_value()); - EXPECT_EQ(30000, time.value()); - - // See `kDefaultKeepaliveTimeout` - auto timeout = GetIntChannelArgument(args, GRPC_ARG_KEEPALIVE_TIMEOUT_MS); - ASSERT_TRUE(timeout.has_value()); - EXPECT_EQ(10000, timeout.value()); -} - -TEST(ClientOptionsTest, OptionsConstructor) { - using ms = std::chrono::milliseconds; - using min = std::chrono::minutes; - auto channel_args = grpc::ChannelArguments(); - channel_args.SetString("test-key-1", "value-1"); - auto credentials = grpc::InsecureChannelCredentials(); - auto options = ClientOptions( - Options{} - .set("testdata.googleapis.com") - .set("testadmin.googleapis.com") - .set("testinstanceadmin.googleapis.com") - .set(credentials) - .set( - TracingOptions{}.SetOptions("single_line_mode=F")) - .set({"test-component"}) - .set(3) - .set(ms(100)) - .set(min(4)) - .set(5) - .set(channel_args) - .set({{"test-key-2", "value-2"}}) - .set({"test-prefix"})); - - EXPECT_EQ("testdata.googleapis.com", options.data_endpoint()); - EXPECT_EQ("testadmin.googleapis.com", options.admin_endpoint()); - EXPECT_EQ("testinstanceadmin.googleapis.com", - ClientOptionsTestTraits::InstanceAdminEndpoint(options)); - EXPECT_EQ(credentials, options.credentials()); - EXPECT_FALSE(options.tracing_options().single_line_mode()); - EXPECT_TRUE(options.tracing_enabled("test-component")); - EXPECT_EQ(3U, options.connection_pool_size()); - EXPECT_EQ(ms(100), options.min_conn_refresh_period()); - EXPECT_EQ(min(4), options.max_conn_refresh_period()); - EXPECT_EQ(5U, options.background_thread_pool_size()); - auto args = options.channel_arguments(); - auto key1 = GetStringChannelArgument(args, "test-key-1"); - ASSERT_TRUE(key1.has_value()); - EXPECT_EQ("value-1", key1.value()); - auto key2 = GetStringChannelArgument(args, "test-key-2"); - ASSERT_TRUE(key2.has_value()); - EXPECT_EQ("value-2", key2.value()); - auto s = GetStringChannelArgument(args, GRPC_ARG_PRIMARY_USER_AGENT_STRING); - ASSERT_TRUE(s.has_value()); - EXPECT_THAT(*s, HasSubstr("test-prefix")); -} - -TEST(ClientOptionsTest, CustomBackgroundThreadsOption) { - struct Fake : BackgroundThreads { - CompletionQueue cq() const override { return {}; } - }; - bool invoked = false; - auto factory = [&invoked] { - invoked = true; - return std::make_unique(); - }; - - auto options = - ClientOptions(Options{}.set(factory)); - - EXPECT_FALSE(invoked); - options.background_threads_factory()(); - EXPECT_TRUE(invoked); -} - -class ClientOptionsDefaultEndpointTest : public ::testing::Test { - public: - ClientOptionsDefaultEndpointTest() - : bigtable_emulator_host_("BIGTABLE_EMULATOR_HOST", - "testendpoint.googleapis.com"), - bigtable_instance_admin_emulator_host_( - "BIGTABLE_INSTANCE_ADMIN_EMULATOR_HOST", {}) {} - - protected: - static std::string GetInstanceAdminEndpoint(ClientOptions const& options) { - return ClientOptionsTestTraits::InstanceAdminEndpoint(options); - } - - ScopedEnvironment bigtable_emulator_host_; - ScopedEnvironment bigtable_instance_admin_emulator_host_; -}; - -TEST_F(ClientOptionsDefaultEndpointTest, Default) { - ClientOptions client_options; - EXPECT_EQ("testendpoint.googleapis.com", client_options.data_endpoint()); - EXPECT_EQ("testendpoint.googleapis.com", client_options.admin_endpoint()); - EXPECT_EQ("testendpoint.googleapis.com", - GetInstanceAdminEndpoint(client_options)); - - // Just check `MakeOptions()` for endpoints here. - auto opts = internal::MakeOptions(std::move(client_options)); - EXPECT_EQ("testendpoint.googleapis.com", opts.get()); - EXPECT_EQ("testendpoint.googleapis.com", opts.get()); - EXPECT_EQ("testendpoint.googleapis.com", - opts.get()); -} - -TEST_F(ClientOptionsDefaultEndpointTest, WithCredentials) { - auto credentials = grpc::GoogleDefaultCredentials(); - ClientOptions tested(credentials); - EXPECT_EQ("bigtable.googleapis.com", tested.data_endpoint()); - EXPECT_EQ("bigtableadmin.googleapis.com", tested.admin_endpoint()); - EXPECT_EQ(credentials.get(), tested.credentials().get()); -} - -TEST_F(ClientOptionsDefaultEndpointTest, DefaultNoEmulator) { - ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", {}); - - auto credentials = grpc::GoogleDefaultCredentials(); - ClientOptions tested(credentials); - EXPECT_EQ("bigtable.googleapis.com", tested.data_endpoint()); - EXPECT_EQ("bigtableadmin.googleapis.com", tested.admin_endpoint()); - EXPECT_EQ("bigtableadmin.googleapis.com", GetInstanceAdminEndpoint(tested)); -} - -TEST_F(ClientOptionsDefaultEndpointTest, SeparateEmulators) { - ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", - "emulator-host:8000"); - ScopedEnvironment bigtable_instance_admin_emulator_host( - "BIGTABLE_INSTANCE_ADMIN_EMULATOR_HOST", "instance-emulator-host:9000"); - ClientOptions actual; - EXPECT_EQ("emulator-host:8000", actual.data_endpoint()); - EXPECT_EQ("emulator-host:8000", actual.admin_endpoint()); - EXPECT_EQ("instance-emulator-host:9000", GetInstanceAdminEndpoint(actual)); -} - -TEST_F(ClientOptionsDefaultEndpointTest, DataNoEnv) { - ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", {}); - EXPECT_EQ("bigtable.googleapis.com", ClientOptions{}.data_endpoint()); -} - -TEST_F(ClientOptionsDefaultEndpointTest, AdminNoEnv) { - ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", {}); - EXPECT_EQ("bigtableadmin.googleapis.com", ClientOptions{}.admin_endpoint()); -} - -TEST_F(ClientOptionsDefaultEndpointTest, AdminEmulatorOverrides) { - ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", - "127.0.0.1:1234"); - EXPECT_EQ("127.0.0.1:1234", ClientOptions{}.admin_endpoint()); -} - -TEST_F(ClientOptionsDefaultEndpointTest, AdminInstanceAdminNoEffect) { - ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", {}); - ScopedEnvironment bigtable_instance_admin_emulator_host( - "BIGTABLE_INSTANCE_ADMIN_EMULATOR_HOST", "127.0.0.1:1234"); - EXPECT_EQ("bigtableadmin.googleapis.com", ClientOptions{}.admin_endpoint()); -} - -TEST_F(ClientOptionsDefaultEndpointTest, InstanceAdminNoEnv) { - ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", {}); - EXPECT_EQ("bigtableadmin.googleapis.com", - GetInstanceAdminEndpoint(ClientOptions())); -} - -TEST_F(ClientOptionsDefaultEndpointTest, InstanceAdminEmulatorOverrides) { - ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", - "127.0.0.1:1234"); - EXPECT_EQ("127.0.0.1:1234", GetInstanceAdminEndpoint(ClientOptions())); -} - -TEST_F(ClientOptionsDefaultEndpointTest, InstanceAdminInstanceAdminOverrides) { - ScopedEnvironment bigtable_emulator_host("BIGTABLE_EMULATOR_HOST", "unused"); - ScopedEnvironment bigtable_instance_admin_emulator_host( - "BIGTABLE_INSTANCE_ADMIN_EMULATOR_HOST", "127.0.0.1:1234"); - EXPECT_EQ("127.0.0.1:1234", GetInstanceAdminEndpoint(ClientOptions())); -} - -TEST(ClientOptionsTest, EditDataEndpoint) { - auto client_options = ClientOptions{}.set_data_endpoint("customendpoint.com"); - EXPECT_EQ("customendpoint.com", client_options.data_endpoint()); -} - -TEST(ClientOptionsTest, EditAdminEndpoint) { - auto client_options = - ClientOptions{}.set_admin_endpoint("customendpoint.com"); - EXPECT_EQ("customendpoint.com", client_options.admin_endpoint()); - EXPECT_EQ("customendpoint.com", - ClientOptionsTestTraits::InstanceAdminEndpoint(client_options)); -} - -TEST(ClientOptionsTest, EditCredentials) { - auto client_options = - ClientOptions{}.SetCredentials(grpc::InsecureChannelCredentials()); - EXPECT_EQ(typeid(grpc::InsecureChannelCredentials()), - typeid(client_options.credentials())); - - auto opts = internal::MakeOptions(std::move(client_options)); - EXPECT_EQ(typeid(grpc::InsecureChannelCredentials()), - typeid(opts.get())); -} - -TEST(ClientOptionsTest, EditConnectionPoolName) { - ClientOptions client_options; - auto& returned = client_options.set_connection_pool_name("foo"); - EXPECT_EQ(&returned, &client_options); - EXPECT_EQ("foo", returned.connection_pool_name()); - - auto opts = internal::MakeOptions(std::move(client_options)); - auto args = google::cloud::internal::MakeChannelArguments(opts); - auto name = GetStringChannelArgument(args, "cbt-c++/connection-pool-name"); - ASSERT_TRUE(name.has_value()); - EXPECT_EQ("foo", name); -} - -TEST(ClientOptionsTest, EditConnectionPoolSize) { - ClientOptions client_options; - auto& returned = client_options.set_connection_pool_size(42); - EXPECT_EQ(&returned, &client_options); - EXPECT_EQ(42UL, returned.connection_pool_size()); - - auto opts = internal::MakeOptions(std::move(client_options)); - EXPECT_EQ(42, opts.get()); -} - -TEST(ClientOptionsTest, ResetToDefaultConnectionPoolSize) { - ClientOptions client_options; - auto& returned = client_options.set_connection_pool_size(0); - EXPECT_EQ(&returned, &client_options); - // The number of connections should be >= 1, we "know" what the actual value - // is, but we do not want a change-detection-test. - EXPECT_LE(1UL, returned.connection_pool_size()); -} - -TEST(ClientOptionsTest, ConnectionPoolSizeDoesNotExceedMax) { - ClientOptions client_options; - auto& returned = client_options.set_connection_pool_size( - BIGTABLE_CLIENT_DEFAULT_CONNECTION_POOL_SIZE_MAX + 1); - EXPECT_EQ(&returned, &client_options); - // The number of connections should be >= 1, we "know" what the actual value - // is, but we do not want a change-detection-test. - EXPECT_LE(BIGTABLE_CLIENT_DEFAULT_CONNECTION_POOL_SIZE_MAX, - returned.connection_pool_size()); -} - -TEST(ClientOptionsTest, SetGrpclbFallbackTimeoutMS) { - // Test milliseconds are set properly to channel_arguments - ClientOptions client_options; - ASSERT_STATUS_OK( - client_options.SetGrpclbFallbackTimeout(std::chrono::milliseconds(5))); - - auto args = client_options.channel_arguments(); - auto actual = - GetIntChannelArgument(args, GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, 5); - - auto opts = internal::MakeOptions(std::move(client_options)); - args = google::cloud::internal::MakeChannelArguments(opts); - actual = GetIntChannelArgument(args, GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, 5); -} - -TEST(ClientOptionsTest, SetGrpclbFallbackTimeoutSec) { - // Test seconds are converted into milliseconds - ClientOptions client_options; - ASSERT_STATUS_OK( - client_options.SetGrpclbFallbackTimeout(std::chrono::seconds(5))); - - auto args = client_options.channel_arguments(); - auto actual = - GetIntChannelArgument(args, GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, 5000); - - auto opts = internal::MakeOptions(std::move(client_options)); - args = google::cloud::internal::MakeChannelArguments(opts); - actual = GetIntChannelArgument(args, GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, 5000); -} - -TEST(ClientOptionsTest, SetGrpclbFallbackTimeoutException) { - // Test if fallback_timeout exceeds int range and StatusCode - // matches kOutOfRange - ClientOptions client_options; - EXPECT_EQ( - client_options.SetGrpclbFallbackTimeout(std::chrono::hours(999)).code(), - google::cloud::StatusCode::kOutOfRange); -} - -TEST(ClientOptionsTest, SetCompressionAlgorithm) { - ClientOptions client_options; - client_options.SetCompressionAlgorithm(GRPC_COMPRESS_NONE); - - auto args = client_options.channel_arguments(); - auto actual = - GetIntChannelArgument(args, GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, GRPC_COMPRESS_NONE); - - auto opts = internal::MakeOptions(std::move(client_options)); - args = google::cloud::internal::MakeChannelArguments(opts); - actual = - GetIntChannelArgument(args, GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, GRPC_COMPRESS_NONE); -} - -TEST(ClientOptionsTest, SetLoadBalancingPolicyName) { - ClientOptions client_options; - client_options.SetLoadBalancingPolicyName("test-policy-name"); - - auto args = client_options.channel_arguments(); - auto actual = GetStringChannelArgument(args, GRPC_ARG_LB_POLICY_NAME); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, "test-policy-name"); - - auto opts = internal::MakeOptions(std::move(client_options)); - args = google::cloud::internal::MakeChannelArguments(opts); - actual = GetStringChannelArgument(args, GRPC_ARG_LB_POLICY_NAME); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, "test-policy-name"); -} - -TEST(ClientOptionsTest, SetServiceConfigJSON) { - ClientOptions client_options; - client_options.SetServiceConfigJSON("test-config"); - - auto args = client_options.channel_arguments(); - auto actual = GetStringChannelArgument(args, GRPC_ARG_SERVICE_CONFIG); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, "test-config"); - - auto opts = internal::MakeOptions(std::move(client_options)); - args = google::cloud::internal::MakeChannelArguments(opts); - actual = GetStringChannelArgument(args, GRPC_ARG_SERVICE_CONFIG); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, "test-config"); -} - -TEST(ClientOptionsTest, SetUserAgentPrefix) { - ClientOptions client_options; - client_options.SetUserAgentPrefix("test_prefix"); - - auto args = client_options.channel_arguments(); - auto actual = - GetStringChannelArgument(args, GRPC_ARG_PRIMARY_USER_AGENT_STRING); - ASSERT_TRUE(actual.has_value()); - EXPECT_THAT(*actual, HasSubstr("test_prefix")); - - auto opts = internal::MakeOptions(std::move(client_options)); - args = google::cloud::internal::MakeChannelArguments(opts); - actual = GetStringChannelArgument(args, GRPC_ARG_PRIMARY_USER_AGENT_STRING); - ASSERT_TRUE(actual.has_value()); - EXPECT_THAT(*actual, HasSubstr("test_prefix")); -} - -TEST(ClientOptionsTest, SetSslTargetNameOverride) { - ClientOptions client_options; - client_options.SetSslTargetNameOverride("test-name"); - - auto args = client_options.channel_arguments(); - auto actual = - GetStringChannelArgument(args, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, "test-name"); - - auto opts = internal::MakeOptions(std::move(client_options)); - args = google::cloud::internal::MakeChannelArguments(opts); - actual = GetStringChannelArgument(args, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG); - ASSERT_TRUE(actual.has_value()); - EXPECT_EQ(*actual, "test-name"); -} - -TEST(ClientOptionsTest, UserAgentPrefix) { - std::string const actual = ClientOptions::UserAgentPrefix(); - EXPECT_THAT(actual, HasSubstr("gl-cpp/")); -} - -TEST(ClientOptionsTest, RefreshPeriod) { - auto options = ClientOptions(); - EXPECT_LE(options.min_conn_refresh_period(), - options.max_conn_refresh_period()); - using ms = std::chrono::milliseconds; - - options.set_min_conn_refresh_period(ms(1000)); - EXPECT_EQ(1000, options.min_conn_refresh_period().count()); - - options.set_max_conn_refresh_period(ms(2000)); - EXPECT_EQ(2000, options.max_conn_refresh_period().count()); - - options.set_min_conn_refresh_period(ms(3000)); - EXPECT_EQ(3000, options.min_conn_refresh_period().count()); - EXPECT_EQ(3000, options.max_conn_refresh_period().count()); - - options.set_max_conn_refresh_period(ms(1500)); - EXPECT_EQ(1500, options.min_conn_refresh_period().count()); - EXPECT_EQ(1500, options.max_conn_refresh_period().count()); - - options.set_max_conn_refresh_period(ms(5000)); - EXPECT_EQ(1500, options.min_conn_refresh_period().count()); - EXPECT_EQ(5000, options.max_conn_refresh_period().count()); - - options.set_min_conn_refresh_period(ms(1000)); - EXPECT_EQ(1000, options.min_conn_refresh_period().count()); - EXPECT_EQ(5000, options.max_conn_refresh_period().count()); - - auto opts = internal::MakeOptions(std::move(options)); - EXPECT_EQ(1000, opts.get().count()); - EXPECT_EQ(5000, opts.get().count()); -} - -TEST(ClientOptionsTest, TracingComponents) { - ScopedEnvironment tracing("GOOGLE_CLOUD_CPP_ENABLE_TRACING", "foo,bar"); - auto options = ClientOptions(); - - // Check defaults - EXPECT_TRUE(options.tracing_enabled("foo")); - EXPECT_TRUE(options.tracing_enabled("bar")); - EXPECT_FALSE(options.tracing_enabled("baz")); - - // Edit components - options.enable_tracing("baz"); - EXPECT_TRUE(options.tracing_enabled("baz")); - options.disable_tracing("foo"); - EXPECT_FALSE(options.tracing_enabled("foo")); - - // Check `MakeOptions()` - auto opts = internal::MakeOptions(std::move(options)); - EXPECT_THAT(opts.get(), - testing::UnorderedElementsAre("bar", "baz")); -} - -TEST(ClientOptionsTest, DefaultTracingOptionsNoEnv) { - ScopedEnvironment tracing("GOOGLE_CLOUD_CPP_TRACING_OPTIONS", absl::nullopt); - - ClientOptions client_options; - auto tracing_options = client_options.tracing_options(); - EXPECT_EQ(TracingOptions(), tracing_options); - - auto opts = internal::MakeOptions(std::move(client_options)); - tracing_options = opts.get(); - EXPECT_EQ(TracingOptions(), tracing_options); -} - -TEST(ClientOptionsTest, DefaultTracingOptionsEnv) { - ScopedEnvironment tracing("GOOGLE_CLOUD_CPP_TRACING_OPTIONS", - "single_line_mode=F"); - - ClientOptions client_options; - auto tracing_options = client_options.tracing_options(); - EXPECT_FALSE(tracing_options.single_line_mode()); - - auto opts = internal::MakeOptions(std::move(client_options)); - tracing_options = opts.get(); - EXPECT_FALSE(tracing_options.single_line_mode()); -} - -TEST(ClientOptionsTest, BackgroundThreadPoolSize) { - using ThreadPool = - ::google::cloud::internal::AutomaticallyCreatedBackgroundThreads; - - auto options = ClientOptions(); - // Check that the default value is 0 or 1. Both values result in the - // BackgroundThreadsFactory creating a ThreadPool with a single thread in it. - EXPECT_GE(1U, options.background_thread_pool_size()); - - auto background = options.background_threads_factory()(); - auto* tp = dynamic_cast(background.get()); - ASSERT_NE(nullptr, tp); - EXPECT_EQ(1U, tp->pool_size()); - - options.set_background_thread_pool_size(5U); - EXPECT_EQ(5U, options.background_thread_pool_size()); - - background = options.background_threads_factory()(); - tp = dynamic_cast(background.get()); - ASSERT_NE(nullptr, tp); - EXPECT_EQ(5U, tp->pool_size()); - - auto opts = internal::MakeOptions(std::move(options)); - EXPECT_EQ(5U, opts.get()); - EXPECT_FALSE(opts.has()); -} - -TEST(ClientOptionsTest, CustomBackgroundThreads) { - auto check = [](CompletionQueue& cq, - std::unique_ptr background) { - using ms = std::chrono::milliseconds; - - // Schedule some work that cannot execute because there is no thread - // draining the completion queue. - promise p; - auto background_thread_id = p.get_future(); - background->cq().RunAsync( - [&p](CompletionQueue&) { p.set_value(std::this_thread::get_id()); }); - EXPECT_NE(std::future_status::ready, background_thread_id.wait_for(ms(10))); - - // Verify we can create our own threads to drain the completion queue. - std::thread t([&cq] { cq.Run(); }); - EXPECT_EQ(t.get_id(), background_thread_id.get()); - - cq.Shutdown(); - t.join(); - }; - - CompletionQueue cq; - auto client_options = ClientOptions().DisableBackgroundThreads(cq); - auto background = client_options.background_threads_factory()(); - - check(cq, std::move(background)); - - cq = CompletionQueue(); - client_options = ClientOptions().DisableBackgroundThreads(cq); - auto opts = internal::MakeOptions(std::move(client_options)); - background = - google::cloud::internal::MakeBackgroundThreadsFactory(std::move(opts))(); - - check(cq, std::move(background)); -} - -} // namespace -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace bigtable -} // namespace cloud -} // namespace google diff --git a/google/cloud/bigtable/data_client.cc b/google/cloud/bigtable/data_client.cc index 9932d24c541e7..a322312de873c 100644 --- a/google/cloud/bigtable/data_client.cc +++ b/google/cloud/bigtable/data_client.cc @@ -229,13 +229,6 @@ std::shared_ptr MakeDataClient(std::string project_id, return client; } -std::shared_ptr CreateDefaultDataClient(std::string project_id, - std::string instance_id, - ClientOptions options) { - return MakeDataClient(std::move(project_id), std::move(instance_id), - internal::MakeOptions(std::move(options))); -} - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable } // namespace cloud diff --git a/google/cloud/bigtable/data_client.h b/google/cloud/bigtable/data_client.h index eb7f376cc4483..37397f68d8c52 100644 --- a/google/cloud/bigtable/data_client.h +++ b/google/cloud/bigtable/data_client.h @@ -15,10 +15,11 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_DATA_CLIENT_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_DATA_CLIENT_H -#include "google/cloud/bigtable/client_options.h" #include "google/cloud/bigtable/completion_queue.h" #include "google/cloud/bigtable/row.h" #include "google/cloud/bigtable/version.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/grpc_options.h" #include "google/bigtable/v2/bigtable.grpc.pb.h" #include @@ -205,17 +206,6 @@ std::shared_ptr MakeDataClient(std::string project_id, std::string instance_id, Options options = {}); -/** - * Create a new data client configured via @p options. - * - * @deprecated use the `MakeDataClient` method which accepts - * `google::cloud::Options` instead. - */ -GOOGLE_CLOUD_CPP_DEPRECATED("use `MakeDataClient` instead") -std::shared_ptr CreateDefaultDataClient(std::string project_id, - std::string instance_id, - ClientOptions options); - /** * Return the fully qualified instance name for the @p client. * diff --git a/google/cloud/bigtable/data_client_test.cc b/google/cloud/bigtable/data_client_test.cc index 2fcc28caad549..da0227d3feaff 100644 --- a/google/cloud/bigtable/data_client_test.cc +++ b/google/cloud/bigtable/data_client_test.cc @@ -23,29 +23,6 @@ namespace bigtable { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { -// TODO(#8800) - remove after `DataClient` deprecation is complete -#include "google/cloud/internal/disable_deprecation_warnings.inc" - -TEST(DataClientTest, Default) { - auto data_client = - CreateDefaultDataClient("test-project", "test-instance", - ClientOptions().set_connection_pool_size(1)); - ASSERT_TRUE(data_client); - EXPECT_EQ("test-project", data_client->project_id()); - EXPECT_EQ("test-instance", data_client->instance_id()); - - auto channel0 = data_client->Channel(); - EXPECT_TRUE(channel0); - - auto channel1 = data_client->Channel(); - EXPECT_EQ(channel0.get(), channel1.get()); - - data_client->reset(); - channel1 = data_client->Channel(); - EXPECT_TRUE(channel1); - EXPECT_NE(channel0.get(), channel1.get()); -} - TEST(DataClientTest, MakeClient) { auto data_client = MakeDataClient("test-project", "test-instance", Options{}.set(1)); @@ -65,9 +42,6 @@ TEST(DataClientTest, MakeClient) { EXPECT_NE(channel0.get(), channel1.get()); } -// TODO(#8800) - remove after `DataClient` deprecation is complete -#include "google/cloud/internal/diagnostics_pop.inc" - TEST(DataClientTest, Logging) { testing_util::ScopedEnvironment env("GOOGLE_CLOUD_CPP_ENABLE_TRACING", "rpc"); diff --git a/google/cloud/bigtable/data_connection.h b/google/cloud/bigtable/data_connection.h index edfdc52e2a015..2ff911892880a 100644 --- a/google/cloud/bigtable/data_connection.h +++ b/google/cloud/bigtable/data_connection.h @@ -180,7 +180,6 @@ class DataConnection { * - `google::cloud::GrpcOptionList` * - `google::cloud::UnifiedCredentialsOptionList` * - `google::cloud::bigtable::AppProfileIdOption` - * - `google::cloud::bigtable::ClientOptionsList` * - `google::cloud::bigtable::DataPolicyOptionList` * * @note Unrecognized options will be ignored. To debug issues with options set diff --git a/google/cloud/bigtable/examples/bigtable_instance_admin_snippets.cc b/google/cloud/bigtable/examples/bigtable_instance_admin_snippets.cc index 0f7984a08ad8b..3ae4f9e1c1c2c 100644 --- a/google/cloud/bigtable/examples/bigtable_instance_admin_snippets.cc +++ b/google/cloud/bigtable/examples/bigtable_instance_admin_snippets.cc @@ -23,6 +23,7 @@ #include "google/cloud/location.h" #include "google/cloud/log.h" #include "google/cloud/project.h" +#include "absl/strings/match.h" #include namespace { diff --git a/google/cloud/bigtable/google_cloud_cpp_bigtable.bzl b/google/cloud/bigtable/google_cloud_cpp_bigtable.bzl index c5d4f47beff0b..6ce24ede53f23 100644 --- a/google/cloud/bigtable/google_cloud_cpp_bigtable.bzl +++ b/google/cloud/bigtable/google_cloud_cpp_bigtable.bzl @@ -52,7 +52,6 @@ google_cloud_cpp_bigtable_hdrs = [ "bytes.h", "cell.h", "client.h", - "client_options.h", "cluster_config.h", "cluster_list_responses.h", "column_family.h", @@ -183,7 +182,6 @@ google_cloud_cpp_bigtable_srcs = [ "bound_query.cc", "bytes.cc", "client.cc", - "client_options.cc", "cluster_config.cc", "data_client.cc", "data_connection.cc", diff --git a/google/cloud/bigtable/instance_admin_client.cc b/google/cloud/bigtable/instance_admin_client.cc index d95811843a370..1309858e2d537 100644 --- a/google/cloud/bigtable/instance_admin_client.cc +++ b/google/cloud/bigtable/instance_admin_client.cc @@ -27,12 +27,6 @@ std::shared_ptr MakeInstanceAdminClient( new InstanceAdminClient(std::move(project), std::move(options))); } -std::shared_ptr CreateDefaultInstanceAdminClient( - std::string project, ClientOptions options) { - return MakeInstanceAdminClient(std::move(project), - internal::MakeOptions(std::move(options))); -} - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable } // namespace cloud diff --git a/google/cloud/bigtable/instance_admin_client.h b/google/cloud/bigtable/instance_admin_client.h index 7bdf232416a50..e5c9e1acfb394 100644 --- a/google/cloud/bigtable/instance_admin_client.h +++ b/google/cloud/bigtable/instance_admin_client.h @@ -16,7 +16,6 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INSTANCE_ADMIN_CLIENT_H #include "google/cloud/bigtable/admin/bigtable_instance_admin_connection.h" -#include "google/cloud/bigtable/client_options.h" #include "google/cloud/bigtable/version.h" #include #include @@ -62,16 +61,6 @@ class InstanceAdminClient final { std::shared_ptr MakeInstanceAdminClient( std::string project, Options options = {}); -/** - * Create a new instance admin client configured via @p options. - * - * @deprecated use the `MakeInstanceAdminClient` method which accepts - * `google::cloud::Options` instead. - */ -GOOGLE_CLOUD_CPP_DEPRECATED("use `MakeInstanceAdminClient` instead") -std::shared_ptr CreateDefaultInstanceAdminClient( - std::string project, ClientOptions options); - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable } // namespace cloud diff --git a/google/cloud/bigtable/instance_admin_client_test.cc b/google/cloud/bigtable/instance_admin_client_test.cc index 2d86e882d2965..a6cff0f75240a 100644 --- a/google/cloud/bigtable/instance_admin_client_test.cc +++ b/google/cloud/bigtable/instance_admin_client_test.cc @@ -21,16 +21,6 @@ namespace bigtable { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { -#include "google/cloud/internal/disable_deprecation_warnings.inc" - -TEST(InstanceAdminClientTest, CreateDefaultClient) { - auto admin_client = CreateDefaultInstanceAdminClient("test-project", {}); - ASSERT_TRUE(admin_client); - EXPECT_EQ("test-project", admin_client->project()); -} - -#include "google/cloud/internal/diagnostics_pop.inc" - TEST(InstanceAdminClientTest, MakeClient) { auto admin_client = MakeInstanceAdminClient("test-project"); ASSERT_TRUE(admin_client); diff --git a/google/cloud/bigtable/instance_admin_test.cc b/google/cloud/bigtable/instance_admin_test.cc index a556750b81985..433eb80c5dc89 100644 --- a/google/cloud/bigtable/instance_admin_test.cc +++ b/google/cloud/bigtable/instance_admin_test.cc @@ -15,6 +15,7 @@ #include "google/cloud/bigtable/instance_admin.h" #include "google/cloud/bigtable/admin/mocks/mock_bigtable_instance_admin_connection.h" #include "google/cloud/bigtable/testing/mock_policies.h" +#include "google/cloud/grpc_options.h" #include "google/cloud/location.h" #include "google/cloud/project.h" #include "google/cloud/testing_util/status_matchers.h" diff --git a/google/cloud/bigtable/internal/bulk_mutator.h b/google/cloud/bigtable/internal/bulk_mutator.h index bd543dc6f0ccc..7b3296821f8e6 100644 --- a/google/cloud/bigtable/internal/bulk_mutator.h +++ b/google/cloud/bigtable/internal/bulk_mutator.h @@ -22,6 +22,7 @@ #include "google/cloud/bigtable/internal/mutate_rows_limiter.h" #include "google/cloud/bigtable/internal/operation_context.h" #include "google/cloud/bigtable/version.h" +#include "google/cloud/idempotency.h" #include "google/cloud/internal/invoke_result.h" #include "google/cloud/status.h" #include @@ -89,7 +90,7 @@ class BulkMutatorState { * request provided by the application. */ int original_index; - Idempotency idempotency; + google::cloud::Idempotency idempotency; /// Set to `false` if the result is unknown. bool has_mutation_result; /** diff --git a/google/cloud/bigtable/mocks/mock_data_connection.h b/google/cloud/bigtable/mocks/mock_data_connection.h index a283af2c9e787..9785393060d63 100644 --- a/google/cloud/bigtable/mocks/mock_data_connection.h +++ b/google/cloud/bigtable/mocks/mock_data_connection.h @@ -16,6 +16,7 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_MOCKS_MOCK_DATA_CONNECTION_H #include "google/cloud/bigtable/data_connection.h" +#include "google/cloud/bigtable/options.h" #include "google/cloud/version.h" #include diff --git a/google/cloud/bigtable/mutation_batcher.h b/google/cloud/bigtable/mutation_batcher.h index 9a7f863832e83..e3d0f5d652243 100644 --- a/google/cloud/bigtable/mutation_batcher.h +++ b/google/cloud/bigtable/mutation_batcher.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_MUTATION_BATCHER_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_MUTATION_BATCHER_H -#include "google/cloud/bigtable/client_options.h" #include "google/cloud/bigtable/completion_queue.h" #include "google/cloud/bigtable/mutations.h" #include "google/cloud/bigtable/table.h" diff --git a/google/cloud/bigtable/table.h b/google/cloud/bigtable/table.h index 00b16e69098ac..fe8f0b269956a 100644 --- a/google/cloud/bigtable/table.h +++ b/google/cloud/bigtable/table.h @@ -34,6 +34,7 @@ #include "google/cloud/bigtable/rpc_retry_policy.h" #include "google/cloud/bigtable/table_resource.h" #include "google/cloud/bigtable/version.h" +#include "google/cloud/background_threads.h" #include "google/cloud/future.h" #include "google/cloud/grpc_error_delegate.h" #include "google/cloud/internal/group_options.h" diff --git a/google/cloud/bigtable/testing/mock_data_client.h b/google/cloud/bigtable/testing/mock_data_client.h index 0a53659246428..38e01022a330b 100644 --- a/google/cloud/bigtable/testing/mock_data_client.h +++ b/google/cloud/bigtable/testing/mock_data_client.h @@ -32,10 +32,6 @@ class MockDataClient : public bigtable::DataClient { explicit MockDataClient(Options options) : options_(std::move(options)) {} - /// @deprecated use constructor that takes `google::cloud::Options` - explicit MockDataClient(ClientOptions options) - : options_(internal::MakeOptions(std::move(options))) {} - MOCK_METHOD(std::string const&, project_id, (), (const, override)); MOCK_METHOD(std::string const&, instance_id, (), (const, override)); MOCK_METHOD(std::shared_ptr, Channel, (), (override)); diff --git a/google/cloud/bigtable/tests/data_integration_test.cc b/google/cloud/bigtable/tests/data_integration_test.cc index 9a835f61176e3..7f8c0ad96e4ec 100644 --- a/google/cloud/bigtable/tests/data_integration_test.cc +++ b/google/cloud/bigtable/tests/data_integration_test.cc @@ -23,6 +23,7 @@ #include "google/cloud/testing_util/scoped_log.h" #include "google/cloud/testing_util/status_matchers.h" #include "absl/strings/str_format.h" +#include "absl/strings/str_split.h" #include namespace google { diff --git a/google/cloud/bigtable/tests/instance_admin_integration_test.cc b/google/cloud/bigtable/tests/instance_admin_integration_test.cc index 20980eb782c04..a3ede81822a16 100644 --- a/google/cloud/bigtable/tests/instance_admin_integration_test.cc +++ b/google/cloud/bigtable/tests/instance_admin_integration_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "google/cloud/bigtable/instance_admin.h" +#include "google/cloud/grpc_options.h" #include "google/cloud/bigtable/testing/random_names.h" #include "google/cloud/internal/algorithm.h" #include "google/cloud/internal/background_threads_impl.h" diff --git a/google/cloud/bigtable/tests/table_sample_rows_integration_test.cc b/google/cloud/bigtable/tests/table_sample_rows_integration_test.cc index bdb78871a410c..bfde41eb7ef1c 100644 --- a/google/cloud/bigtable/tests/table_sample_rows_integration_test.cc +++ b/google/cloud/bigtable/tests/table_sample_rows_integration_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "google/cloud/bigtable/client_options.h" #include "google/cloud/bigtable/data_client.h" #include "google/cloud/bigtable/mutations.h" #include "google/cloud/bigtable/row_key_sample.h" From 1d3d14c32179891cb416ca8d494c80268848b084 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Sat, 20 Dec 2025 01:49:25 +0000 Subject: [PATCH 3/5] run checkers --- doc/v3-migration-guide.md | 62 +++++++++++-------- .../tests/instance_admin_integration_test.cc | 2 +- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/doc/v3-migration-guide.md b/doc/v3-migration-guide.md index 3028f7ca2b838..41e72a28472c1 100644 --- a/doc/v3-migration-guide.md +++ b/doc/v3-migration-guide.md @@ -104,7 +104,6 @@ for (auto& row : table.ReadRows( -
Removed bigtable::ClientOptions @@ -116,40 +115,42 @@ The deprecated `bigtable::ClientOptions` has been removed. Please use The following table shows the mapping from `bigtable::ClientOptions` methods to their `google::cloud::Options` equivalents: -| `bigtable::ClientOptions` method | `google::cloud::Options` equivalent | -| ----------------------------------------------- | ------------------------------------------------------------------------------------------------ | -| `(constructor)` | `google::cloud::Options{}` | -| `set_data_endpoint` |`google::cloud::EndpointOption` | -| `set_admin_endpoint` |`google::cloud::EndpointOption` | -| `set_connection_pool_name` | `google::cloud::GrpcChannelArgumentsOption` or`google::cloud::GrpcChannelArgumentsNativeOption` | -| `set_connection_pool_size` |`google::cloud::GrpcNumChannelsOption` | -| `SetCredentials` |`google::cloud::GrpcCredentialOption` | -| `set_channel_arguments` |`google::cloud::GrpcChannelArgumentsNativeOption`| -| `SetCompressionAlgorithm` |`google::cloud::GrpcChannelArgumentsNativeOption`| -| `SetGrpclbFallbackTimeout` |`google::cloud::GrpcChannelArgumentsNativeOption`| -| `SetUserAgentPrefix` | `google::cloud::UserAgentProductsOption` or`google::cloud::GrpcChannelArgumentsNativeOption` | -| `SetResourceQuota` |`google::cloud::GrpcChannelArgumentsNativeOption` | -| `SetMaxReceiveMessageSize` |`google::cloud::GrpcChannelArgumentsNativeOption` | -| `SetMaxSendMessageSize` |`google::cloud::GrpcChannelArgumentsNativeOption` | -| `SetLoadBalancingPolicyName` |`google::cloud::GrpcChannelArgumentsNativeOption` | -| `SetServiceConfigJSON` |`google::cloud::GrpcChannelArgumentsNativeOption` | -| `SetSslTargetNameOverride` |`google::cloud::GrpcChannelArgumentsNativeOption` | -| `enable_tracing`, `disable_tracing` |`google::cloud::LoggingComponentsOption` | -| `tracing_options` |`google::cloud::GrpcTracingOptionsOption` | -| `set_max_conn_refresh_period` |`bigtable::MaxConnectionRefreshOption` | -| `set_min_conn_refresh_period` |`bigtable::MinConnectionRefreshOption` | -| `set_background_thread_pool_size` |`google::cloud::GrpcBackgroundThreadPoolSizeOption` | -| `DisableBackgroundThreads` |`google::cloud::GrpcCompletionQueueOption` | - -Example usage of the replacements can be found below. +| `bigtable::ClientOptions` method | `google::cloud::Options` equivalent | +| ----------------------------------- | ----------------------------------------------------------------------------------------------- | +| `(constructor)` | `google::cloud::Options{}` | +| `set_data_endpoint` | `google::cloud::EndpointOption` | +| `set_admin_endpoint` | `google::cloud::EndpointOption` | +| `set_connection_pool_name` | `google::cloud::GrpcChannelArgumentsOption` or`google::cloud::GrpcChannelArgumentsNativeOption` | +| `set_connection_pool_size` | `google::cloud::GrpcNumChannelsOption` | +| `SetCredentials` | `google::cloud::GrpcCredentialOption` | +| `set_channel_arguments` | `google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetCompressionAlgorithm` | `google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetGrpclbFallbackTimeout` | `google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetUserAgentPrefix` | `google::cloud::UserAgentProductsOption` or`google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetResourceQuota` | `google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetMaxReceiveMessageSize` | `google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetMaxSendMessageSize` | `google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetLoadBalancingPolicyName` | `google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetServiceConfigJSON` | `google::cloud::GrpcChannelArgumentsNativeOption` | +| `SetSslTargetNameOverride` | `google::cloud::GrpcChannelArgumentsNativeOption` | +| `enable_tracing`, `disable_tracing` | `google::cloud::LoggingComponentsOption` | +| `tracing_options` | `google::cloud::GrpcTracingOptionsOption` | +| `set_max_conn_refresh_period` | `bigtable::MaxConnectionRefreshOption` | +| `set_min_conn_refresh_period` | `bigtable::MinConnectionRefreshOption` | +| `set_background_thread_pool_size` | `google::cloud::GrpcBackgroundThreadPoolSizeOption` | +| `DisableBackgroundThreads` | `google::cloud::GrpcCompletionQueueOption` | + +Example usage of the replacements can be found below. **Before:** + ```cpp auto client = bigtable::Client( bigtable::ClientOptions().set_connection_pool_size(4)); ``` **After:** + ```cpp auto client = bigtable::Client( google::cloud::Options{}.set(4)); @@ -161,6 +162,7 @@ The deprecated `bigtable::CreateDefaultDataClient` function has been removed. Please use `bigtable::MakeDataClient` instead. **Before:** + ```cpp auto client = bigtable::CreateDefaultDataClient( "my-project", "my-instance", @@ -168,6 +170,7 @@ auto client = bigtable::CreateDefaultDataClient( ``` **After:** + ```cpp auto client = bigtable::MakeDataClient( "my-project", "my-instance", @@ -180,12 +183,14 @@ The deprecated `bigtable::CreateDefaultAdminClient` function has been removed. Please use `bigtable::MakeAdminClient` instead. **Before:** + ```cpp auto client = bigtable::CreateDefaultAdminClient( "my-project", bigtable::ClientOptions().set_connection_pool_size(4)); ``` **After:** + ```cpp auto client = bigtable::MakeAdminClient( "my-project", @@ -198,17 +203,20 @@ The deprecated `bigtable::CreateDefaultInstanceAdminClient` function has been removed. Please use `bigtable::MakeInstanceAdminClient` instead. **Before:** + ```cpp auto client = bigtable::CreateDefaultInstanceAdminClient( "my-project", bigtable::ClientOptions().set_connection_pool_size(4)); ``` **After:** + ```cpp auto client = bigtable::MakeInstanceAdminClient( "my-project", google::cloud::Options{}.set(4)); ``` +
### Pubsub diff --git a/google/cloud/bigtable/tests/instance_admin_integration_test.cc b/google/cloud/bigtable/tests/instance_admin_integration_test.cc index a3ede81822a16..9e47f51ff6196 100644 --- a/google/cloud/bigtable/tests/instance_admin_integration_test.cc +++ b/google/cloud/bigtable/tests/instance_admin_integration_test.cc @@ -13,8 +13,8 @@ // limitations under the License. #include "google/cloud/bigtable/instance_admin.h" -#include "google/cloud/grpc_options.h" #include "google/cloud/bigtable/testing/random_names.h" +#include "google/cloud/grpc_options.h" #include "google/cloud/internal/algorithm.h" #include "google/cloud/internal/background_threads_impl.h" #include "google/cloud/internal/getenv.h" From 883c1d55f15a8f812ae4999296cb8b0127edcc26 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Sat, 20 Dec 2025 02:34:37 +0000 Subject: [PATCH 4/5] fix migration doc formatting --- doc/v3-migration-guide.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/v3-migration-guide.md b/doc/v3-migration-guide.md index 41e72a28472c1..f8527df277363 100644 --- a/doc/v3-migration-guide.md +++ b/doc/v3-migration-guide.md @@ -218,6 +218,8 @@ auto client = bigtable::MakeInstanceAdminClient( ``` + + ### Pubsub ### Spanner From 993a88a6545151bb89eba63a76452e141387e5d4 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Sat, 20 Dec 2025 02:58:27 +0000 Subject: [PATCH 5/5] run checkers --- doc/v3-migration-guide.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/v3-migration-guide.md b/doc/v3-migration-guide.md index f8527df277363..2074dcda6dcfd 100644 --- a/doc/v3-migration-guide.md +++ b/doc/v3-migration-guide.md @@ -219,7 +219,6 @@ auto client = bigtable::MakeInstanceAdminClient( - ### Pubsub ### Spanner