diff --git a/ci/abi-dumps/google_cloud_cpp_spanner.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_spanner.expected.abi.dump.gz index 1a9a8c2a76ed5..9a6270afce72c 100644 Binary files a/ci/abi-dumps/google_cloud_cpp_spanner.expected.abi.dump.gz and b/ci/abi-dumps/google_cloud_cpp_spanner.expected.abi.dump.gz differ diff --git a/doc/v3-migration-guide.md b/doc/v3-migration-guide.md index 9421abcddc5fc..92295b74728fe 100644 --- a/doc/v3-migration-guide.md +++ b/doc/v3-migration-guide.md @@ -125,4 +125,45 @@ auto limit = google::cloud::bigtable::RowReader::NO_ROWS_LIMIT; ### Spanner +
+Removed spanner::ClientOptions class + +The `spanner::ClientOptions` class has been removed. Use +`google::cloud::Options` instead to set the following as needed: + +- `spanner::QueryOptimizerVersionOption` +- `spanner::QueryOptimizerStatisticsPackageOption` +- `spanner::RequestPriorityOption` +- `spanner::RequestTagOption` + +**Before:** + +```cpp +#include "google/cloud/spanner/client.h" + +// ... + +namespace spanner = ::google::cloud::spanner; +auto client_options = spanner::ClientOptions().set_query_options( + spanner::QueryOptions().set_optimizer_version("1")); + +auto client = spanner::Client(connection, client_options); +``` + +**After:** + +```cpp +#include "google/cloud/spanner/client.h" +#include "google/cloud/spanner/options.h" + +// ... + +namespace spanner = ::google::cloud::spanner; +auto options = google::cloud::Options{}.set("1"); + +auto client = spanner::Client(connection, options); +``` + +
+ ### Storage diff --git a/google/cloud/spanner/CMakeLists.txt b/google/cloud/spanner/CMakeLists.txt index acb029537fecb..45f31b94109a6 100644 --- a/google/cloud/spanner/CMakeLists.txt +++ b/google/cloud/spanner/CMakeLists.txt @@ -97,7 +97,6 @@ add_library( bytes.h client.cc client.h - client_options.h commit_options.cc commit_options.h commit_result.h @@ -456,7 +455,6 @@ function (spanner_client_define_tests) # cmake-format: sort backup_test.cc bytes_test.cc - client_options_test.cc client_test.cc commit_options_test.cc connection_options_test.cc diff --git a/google/cloud/spanner/client.h b/google/cloud/spanner/client.h index 896687684f68c..45ccea68bb58c 100644 --- a/google/cloud/spanner/client.h +++ b/google/cloud/spanner/client.h @@ -16,7 +16,6 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_CLIENT_H #include "google/cloud/spanner/batch_dml_result.h" -#include "google/cloud/spanner/client_options.h" #include "google/cloud/spanner/commit_options.h" #include "google/cloud/spanner/commit_result.h" #include "google/cloud/spanner/connection.h" @@ -717,14 +716,9 @@ class Client { StatusOr ExecutePartitionedDml(SqlStatement statement, Options opts = {}); - ///@{ - /// @name Backwards compatibility for ClientOptions. - explicit Client(std::shared_ptr conn, ClientOptions const& opts) - : Client(std::move(conn), Options(opts)) {} explicit Client(std::shared_ptr conn, std::initializer_list) : Client(std::move(conn)) {} - ///@} ///@{ /// @name Backwards compatibility for ReadOptions. diff --git a/google/cloud/spanner/client_options.cc b/google/cloud/spanner/client_options.cc deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/google/cloud/spanner/client_options.h b/google/cloud/spanner/client_options.h deleted file mode 100644 index 05b383f979d35..0000000000000 --- a/google/cloud/spanner/client_options.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2020 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_SPANNER_CLIENT_OPTIONS_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_CLIENT_OPTIONS_H - -#include "google/cloud/spanner/query_options.h" -#include "google/cloud/spanner/version.h" -#include "google/cloud/options.h" - -namespace google { -namespace cloud { -namespace spanner { -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN - -/** - * ClientOptions allows the caller to set a variety of options when - * constructing a `Client` instance. - * - * @deprecated Use [`Options`](@ref google::cloud::Options) instead, - * and set (as needed) - * [`QueryOptimizerVersionOption`]( - * @ref google::cloud::spanner::QueryOptimizerVersionOption), - * [`QueryOptimizerStatisticsPackageOption`]( - * @ref google::cloud::spanner::QueryOptimizerStatisticsPackageOption), - * [`RequestPriorityOption`]( - * @ref google::cloud::spanner::RequestPriorityOption), or - * [`RequestTagOption`]( - * @ref google::cloud::spanner::RequestTagOption). - */ -class ClientOptions { - public: - ClientOptions() = default; - ClientOptions(ClientOptions const&) = default; - ClientOptions& operator=(ClientOptions const&) = default; - ClientOptions(ClientOptions&&) = default; - ClientOptions& operator=(ClientOptions&&) = default; - - /** - * Convert the `ClientOptions` to the new, recommended way to represent - * options of all varieties, `google::cloud::Options`. - */ - explicit operator Options() const { return Options(query_options_); } - - /// Returns the `QueryOptions` - QueryOptions const& query_options() const { return query_options_; } - - /// Sets the `QueryOptions` - ClientOptions& set_query_options(QueryOptions qo) { - query_options_ = std::move(qo); - return *this; - } - - friend bool operator==(ClientOptions const& a, ClientOptions const& b) { - return a.query_options_ == b.query_options_; - } - - friend bool operator!=(ClientOptions const& a, ClientOptions const& b) { - return !(a == b); - } - - private: - QueryOptions query_options_; -}; - -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace spanner -} // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_CLIENT_OPTIONS_H diff --git a/google/cloud/spanner/client_options_test.cc b/google/cloud/spanner/client_options_test.cc deleted file mode 100644 index 0fb24f2896570..0000000000000 --- a/google/cloud/spanner/client_options_test.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2020 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/spanner/client_options.h" -#include "google/cloud/spanner/options.h" -#include "google/cloud/spanner/query_options.h" -#include "google/cloud/spanner/version.h" -#include - -namespace google { -namespace cloud { -namespace spanner { -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -namespace { - -TEST(ClientOptionsTest, OptimizerVersion) { - ClientOptions const default_constructed{}; - EXPECT_EQ(QueryOptions{}, default_constructed.query_options()); - - auto copy = default_constructed; - EXPECT_EQ(copy, default_constructed); - - copy.set_query_options(QueryOptions{}.set_optimizer_version("foo")); - EXPECT_NE(copy, default_constructed); - - copy.set_query_options(QueryOptions{}); - EXPECT_EQ(copy, default_constructed); -} - -TEST(ClientOptionsTest, OptionsConversionEmpty) { - ClientOptions const client_options; - auto const options = Options(client_options); - EXPECT_FALSE(options.has()); - EXPECT_FALSE(options.has()); - EXPECT_FALSE(options.has()); - EXPECT_FALSE(options.has()); -} - -TEST(ClientOptionsTest, OptionsConversionFull) { - auto query_options = QueryOptions{} - .set_optimizer_version("1") - .set_optimizer_statistics_package("latest") - .set_request_priority(RequestPriority::kHigh) - .set_request_tag("tag"); - ClientOptions client_options; - client_options.set_query_options(std::move(query_options)); - auto const options = Options(client_options); - EXPECT_TRUE(options.has()); - EXPECT_EQ(options.get(), "1"); - EXPECT_TRUE(options.has()); - EXPECT_EQ(options.get(), "latest"); - EXPECT_TRUE(options.has()); - EXPECT_EQ(options.get(), RequestPriority::kHigh); - EXPECT_TRUE(options.has()); - EXPECT_EQ(options.get(), "tag"); -} - -} // namespace -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace spanner -} // namespace cloud -} // namespace google diff --git a/google/cloud/spanner/client_test.cc b/google/cloud/spanner/client_test.cc index 6f628eb43c9bc..626b6e207479f 100644 --- a/google/cloud/spanner/client_test.cc +++ b/google/cloud/spanner/client_test.cc @@ -1313,26 +1313,6 @@ TEST(ClientTest, UsesConnectionOptions) { EXPECT_STATUS_OK(rollback); } -TEST(ClientTest, UsesClientOptions) { - auto conn = std::make_shared(); - auto txn = MakeReadWriteTransaction(); - - EXPECT_CALL(*conn, options).WillOnce([] { - return Options{}.set("connection"); - }); - EXPECT_CALL(*conn, Rollback) - .WillOnce([txn](Connection::RollbackParams const& params) { - auto const& options = internal::CurrentOptions(); - EXPECT_THAT(options.get(), Eq("client")); - EXPECT_THAT(params.transaction, Eq(txn)); - return Status(); - }); - - Client client(conn, Options{}.set("client")); - auto rollback = client.Rollback(txn, Options{}); - EXPECT_STATUS_OK(rollback); -} - TEST(ClientTest, UsesOperationOptions) { auto conn = std::make_shared(); auto txn = MakeReadWriteTransaction(); diff --git a/google/cloud/spanner/google_cloud_cpp_spanner.bzl b/google/cloud/spanner/google_cloud_cpp_spanner.bzl index 2225628fa9d8e..2af9913dea918 100644 --- a/google/cloud/spanner/google_cloud_cpp_spanner.bzl +++ b/google/cloud/spanner/google_cloud_cpp_spanner.bzl @@ -51,7 +51,6 @@ google_cloud_cpp_spanner_hdrs = [ "batch_dml_result.h", "bytes.h", "client.h", - "client_options.h", "commit_options.h", "commit_result.h", "connection.h", diff --git a/google/cloud/spanner/spanner_client_unit_tests.bzl b/google/cloud/spanner/spanner_client_unit_tests.bzl index ad40b1f607946..48a27efd43ae0 100644 --- a/google/cloud/spanner/spanner_client_unit_tests.bzl +++ b/google/cloud/spanner/spanner_client_unit_tests.bzl @@ -19,7 +19,6 @@ spanner_client_unit_tests = [ "backup_test.cc", "bytes_test.cc", - "client_options_test.cc", "client_test.cc", "commit_options_test.cc", "connection_options_test.cc",