diff --git a/BUILD.bazel b/BUILD.bazel index dff88bb209152..6b5fb61a4a330 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -153,6 +153,23 @@ bool_flag( visibility = ["//:__subpackages__"], ) +cc_library( + name = "storage_grpc", + hdrs = ["//google/cloud/storage:public_grpc_hdrs"], + deps = [ + "//google/cloud/storage:google_cloud_cpp_storage_grpc", + ], +) + +cc_library( + name = "storage_grpc_mocks", + testonly = True, + hdrs = ["//google/cloud/storage:grpc_mocks_hdrs"], + deps = [ + "//google/cloud/storage:google_cloud_cpp_storage_grpc_mocks", + ], +) + cc_library( name = "experimental-storage_grpc", hdrs = ["//google/cloud/storage:public_grpc_hdrs"], diff --git a/CHANGELOG.md b/CHANGELOG.md index 16850eb724fec..cbf5106c20e81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ the APIs in these libraries are stable, and are ready for production use. `CatalogServiceClient` - [Network Services API](/google/cloud/networkservices/README.md) - new `DepServiceClient` +- [Google Cloud Storage](/google/cloud/storage/README.md) - the gRPC plugin is + now GA. The [Using the gRPC plugin][storage-grpc] guide describe this feature + in more detail. ## v2.22.0 - 2024-03 @@ -1443,3 +1446,4 @@ case it elicits some feedback that requires changes. [product-launch-stages]: https://cloud.google.com/products/#product-launch-stages [resource-manager-tags]: https://cloud.google.com/resource-manager/docs/tags/tags-overview [speech-model-adaptation]: https://cloud.google.com/speech-to-text/docs/adaptation-model +[storage-grpc]: https://cloud.google.com/cpp/docs/reference/storage/latest/storage-grpc diff --git a/ci/abi-dumps/google_cloud_cpp_storage_grpc.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_storage_grpc.expected.abi.dump.gz new file mode 100644 index 0000000000000..a94f2b574ac69 Binary files /dev/null and b/ci/abi-dumps/google_cloud_cpp_storage_grpc.expected.abi.dump.gz differ diff --git a/ci/cloudbuild/builds/checkers.sh b/ci/cloudbuild/builds/checkers.sh index 22baff0eac21b..85b817dc42654 100755 --- a/ci/cloudbuild/builds/checkers.sh +++ b/ci/cloudbuild/builds/checkers.sh @@ -211,6 +211,9 @@ time { mapfile -t libraries < <(features::libraries) for library in "${libraries[@]}" opentelemetry; do + if [[ "${library}" == "storage_grpc" ]]; then + continue + fi ci/generate-markdown/update-library-readme.sh "${library}" done } diff --git a/ci/cloudbuild/builds/cmake-install.sh b/ci/cloudbuild/builds/cmake-install.sh index 269369c1d0e65..461c6372eb4cc 100755 --- a/ci/cloudbuild/builds/cmake-install.sh +++ b/ci/cloudbuild/builds/cmake-install.sh @@ -208,7 +208,7 @@ env -C "${out_dir}" ctest "${ctest_args[@]}" # shellcheck disable=SC2046 feature_list="$(printf "%s;" $(features::libraries))" # GCS+gRPC and OpenTelemetry also have quickstarts. -feature_list="${feature_list}experimental-storage_grpc;opentelemetry" +feature_list="${feature_list}opentelemetry" cmake -G Ninja \ -S "${PROJECT_ROOT}/ci/verify_quickstart" \ -B "${PROJECT_ROOT}/cmake-out/quickstart" \ diff --git a/ci/cloudbuild/builds/cmake-split-install.sh b/ci/cloudbuild/builds/cmake-split-install.sh index b9f8e264ea0f5..a5fda92cf1836 100755 --- a/ci/cloudbuild/builds/cmake-split-install.sh +++ b/ci/cloudbuild/builds/cmake-split-install.sh @@ -50,7 +50,7 @@ io::log_h2 "Building and installing popular libraries" mapfile -t core_cmake_args < <(cmake::common_args cmake-out/popular-libraries) io::run cmake "${core_cmake_args[@]}" "${install_args[@]}" \ -DCMAKE_PREFIX_PATH="${INSTALL_PREFIX}" \ - -DGOOGLE_CLOUD_CPP_ENABLE="bigtable,pubsub,spanner,storage,iam,policytroubleshooter" \ + -DGOOGLE_CLOUD_CPP_ENABLE="bigtable,pubsub,spanner,storage,storage_grpc,.iam,policytroubleshooter" \ -DGOOGLE_CLOUD_CPP_USE_INSTALLED_COMMON=ON io::run cmake --build cmake-out/popular-libraries io::run cmake --install cmake-out/popular-libraries --prefix "${INSTALL_PREFIX}" @@ -71,13 +71,13 @@ mapfile -t feature_cmake_args < <(cmake::common_args cmake-out/features) io::run cmake "${feature_cmake_args[@]}" "${install_args[@]}" \ -DCMAKE_PREFIX_PATH="${INSTALL_PREFIX}" \ -DGOOGLE_CLOUD_CPP_USE_INSTALLED_COMMON=ON \ - -DGOOGLE_CLOUD_CPP_ENABLE="__ga_libraries__,-bigtable,-pubsub,-storage,-spanner,-iam,-policytroubleshooter,-compute" + -DGOOGLE_CLOUD_CPP_ENABLE="__ga_libraries__,-bigtable,-pubsub,-storage,-storage_grpc,-spanner,-iam,-policytroubleshooter,-compute" io::run cmake --build cmake-out/features io::run cmake --install cmake-out/features --prefix "${INSTALL_PREFIX}" # Tests the installed artifacts by building all the quickstarts. # shellcheck disable=SC2046 -mapfile -t feature_list < <(cmake -P cmake/print-ga-features.cmake 2>&1) +mapfile -t feature_list < <(cmake -P cmake/print-ga-features.cmake 2>&1 | grep -v storage_grpc) FEATURES=$(printf ";%s" "${feature_list[@]}") FEATURES="${FEATURES:1}" io::run cmake -G Ninja \ diff --git a/ci/cloudbuild/builds/lib/features.sh b/ci/cloudbuild/builds/lib/features.sh index c82745a28e614..87d9e0ed17f68 100755 --- a/ci/cloudbuild/builds/lib/features.sh +++ b/ci/cloudbuild/builds/lib/features.sh @@ -62,7 +62,6 @@ function features::libraries() { function features::_internal_extra() { local list=( experimental-bigquery_rest - experimental-storage_grpc opentelemetry ) printf "%s\n" "${list[@]}" diff --git a/ci/cloudbuild/builds/lib/quickstart.sh b/ci/cloudbuild/builds/lib/quickstart.sh index 88156fccda2d1..2d923ced025c0 100644 --- a/ci/cloudbuild/builds/lib/quickstart.sh +++ b/ci/cloudbuild/builds/lib/quickstart.sh @@ -101,12 +101,12 @@ function quickstart::run_gcs_grpc_quickstart() { io::log_h2 "Running quickstart for GCS+gRPC" io::log "[ CMake ]" - local cmake_bin_dir="${PROJECT_ROOT}/cmake-out/quickstart/cmake-storage" + local cmake_bin_dir="${PROJECT_ROOT}/cmake-out/quickstart/cmake-storage_grpc" "${cmake_bin_dir}/quickstart_grpc" "${run_args[@]}" echo io::log "[ Make ]" - local makefile_bin_dir="${PROJECT_ROOT}/cmake-out/quickstart/makefile-storage" + local makefile_bin_dir="${PROJECT_ROOT}/cmake-out/quickstart/makefile-storage_grpc" LD_LIBRARY_PATH="${prefix}/lib64:${prefix}/lib:${LD_LIBRARY_PATH:-}" \ "${makefile_bin_dir}/quickstart_grpc" "${run_args[@]}" } diff --git a/ci/generate-markdown/generate-readme.sh b/ci/generate-markdown/generate-readme.sh index 8dc0072ef0ff7..e9e2187129e20 100755 --- a/ci/generate-markdown/generate-readme.sh +++ b/ci/generate-markdown/generate-readme.sh @@ -34,7 +34,7 @@ file="README.md" ) | sponge "${file}" ( - mapfile -t features < <(cmake -P cmake/print-ga-features.cmake 2>&1 | LC_ALL=C sort) + mapfile -t features < <(cmake -P cmake/print-ga-features.cmake 2>&1 | LC_ALL=C sort | grep -v storage_grpc) sed '//q' "${file}" for feature in "${features[@]}"; do if [[ "${feature}" == "oauth2" ]]; then diff --git a/ci/verify_current_targets/BUILD.bazel b/ci/verify_current_targets/BUILD.bazel index 77f78e14b46b7..f85f2ed556059 100644 --- a/ci/verify_current_targets/BUILD.bazel +++ b/ci/verify_current_targets/BUILD.bazel @@ -25,7 +25,8 @@ CURRENT_TARGETS = [ ":pubsub", ":spanner", ":storage", - ":experimental-storage_grpc", + ":storage_grpc", + ":storage_grpc_mocks", ] [cc_test( diff --git a/ci/verify_current_targets/CMakeLists.txt b/ci/verify_current_targets/CMakeLists.txt index c1ec5884592a7..2e98ae3b1ede0 100644 --- a/ci/verify_current_targets/CMakeLists.txt +++ b/ci/verify_current_targets/CMakeLists.txt @@ -40,7 +40,7 @@ set(ga_libraries # Define experimental libraries. The only difference is the name of the CMake # targets. set(experimental_libraries # cmake-format: sort - bigquery_rest storage_grpc_mocks) + bigquery_rest) # CMake can use pkg-config to find dependencies. We recommend using CMake # targets, but we want to verify our pkg-config files remain usable and @@ -59,7 +59,7 @@ foreach (library ${common_libraries} ${ga_libraries} ${experimental_libraries}) find_package("google_cloud_cpp_${library}" REQUIRED) endforeach () -foreach (library ${common_libraries} ${ga_libraries}) +foreach (library ${common_libraries} ${ga_libraries} storage_grpc) add_test_case(test_cmake_${library} google-cloud-cpp::${library}) endforeach () diff --git a/ci/verify_quickstart/CMakeLists.txt b/ci/verify_quickstart/CMakeLists.txt index b1f0809411566..0a11ce9fc3868 100644 --- a/ci/verify_quickstart/CMakeLists.txt +++ b/ci/verify_quickstart/CMakeLists.txt @@ -56,7 +56,7 @@ function (add_cmake_quickstart_target feature library target) PREFIX "${PROJECT_BINARY_DIR}/cmake-${library}-prefix" SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../google/cloud/${library}/quickstart" - BINARY_DIR "${PROJECT_BINARY_DIR}/cmake-${library}" + BINARY_DIR "${PROJECT_BINARY_DIR}/cmake-${feature}" CMAKE_ARGS ${COMMON_CMAKE_ARGS} BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "" "--target" "${target}" @@ -79,7 +79,7 @@ function (add_make_quickstart_target feature library target) PREFIX "${PROJECT_BINARY_DIR}/makefile-${library}-prefix" SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../google/cloud/${library}/quickstart" - BINARY_DIR "${PROJECT_BINARY_DIR}/makefile-${library}" + BINARY_DIR "${PROJECT_BINARY_DIR}/makefile-${feature}" CONFIGURE_COMMAND "" BUILD_COMMAND "env" @@ -100,7 +100,7 @@ function (add_make_quickstart_target feature library target) endfunction () foreach (feature IN LISTS FEATURES) - if ("${feature}" STREQUAL "experimental-storage_grpc") + if ("${feature}" STREQUAL "storage_grpc") add_cmake_quickstart_target("${feature}" storage quickstart_grpc) add_make_quickstart_target("${feature}" storage quickstart_grpc) continue() diff --git a/cmake/GoogleCloudCppFeatures.cmake b/cmake/GoogleCloudCppFeatures.cmake index c0ddc672abd1b..91d4c283da682 100644 --- a/cmake/GoogleCloudCppFeatures.cmake +++ b/cmake/GoogleCloudCppFeatures.cmake @@ -37,7 +37,7 @@ set(GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES "storagecontrol") set(GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES # cmake-format: sort -) + "storage_grpc") set(GOOGLE_CLOUD_CPP_GA_LIBRARIES # cmake-format: sort diff --git a/google/cloud/grpc_options.h b/google/cloud/grpc_options.h index 870d716d404d1..7fa3a3e3f2380 100644 --- a/google/cloud/grpc_options.h +++ b/google/cloud/grpc_options.h @@ -60,7 +60,7 @@ struct GrpcCompressionAlgorithmOption { * - `pubsub::MakePublisherConnection()` * - `pubsub::MakeSubscriberConnection()` * - `spanner::MakeConnection()` - * - `storage_experimental::DefaultGrpcClient()` + * - `storage::MakeGrpcClient()` * * @ingroup options */ diff --git a/google/cloud/storage/CMakeLists.txt b/google/cloud/storage/CMakeLists.txt index 1afc6abab92f9..b6b97d0937b8e 100644 --- a/google/cloud/storage/CMakeLists.txt +++ b/google/cloud/storage/CMakeLists.txt @@ -65,7 +65,7 @@ endif () add_executable(storage_quickstart_grpc "quickstart/quickstart_grpc.cc") target_link_libraries(storage_quickstart_grpc - PRIVATE google-cloud-cpp::experimental-storage_grpc) + PRIVATE google-cloud-cpp::storage_grpc) google_cloud_cpp_add_common_options(storage_quickstart_grpc) add_test( NAME storage_quickstart_grpc @@ -78,7 +78,7 @@ set_tests_properties(storage_quickstart_grpc add_executable(storage_quickstart_async "quickstart/quickstart_async.cc") target_link_libraries(storage_quickstart_async - PRIVATE google-cloud-cpp::experimental-storage_grpc) + PRIVATE google-cloud-cpp::storage_grpc) google_cloud_cpp_add_common_options(storage_quickstart_async) add_test( NAME storage_quickstart_async diff --git a/google/cloud/storage/async/client.h b/google/cloud/storage/async/client.h index 1784695208487..9194b14078e27 100644 --- a/google/cloud/storage/async/client.h +++ b/google/cloud/storage/async/client.h @@ -29,6 +29,12 @@ namespace google { namespace cloud { +/** + * Contains experimental features for the GCS C++ Client Library. + * + * @warning The types, functions, aliases, and objects in this namespace are + * subject to change without notice. + */ namespace storage_experimental { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN diff --git a/google/cloud/storage/benchmarks/BUILD.bazel b/google/cloud/storage/benchmarks/BUILD.bazel index 0f8213e26fad9..85a241ff8337c 100644 --- a/google/cloud/storage/benchmarks/BUILD.bazel +++ b/google/cloud/storage/benchmarks/BUILD.bazel @@ -81,7 +81,7 @@ cc_binary( tags = ["manual"], deps = [ ":storage_benchmarks", - "//:experimental-storage_grpc", + "//:storage_grpc", "//google/cloud/testing_util:google_cloud_cpp_testing_private", ], ) diff --git a/google/cloud/storage/benchmarks/CMakeLists.txt b/google/cloud/storage/benchmarks/CMakeLists.txt index 2590871e95774..b9ab6478b3588 100644 --- a/google/cloud/storage/benchmarks/CMakeLists.txt +++ b/google/cloud/storage/benchmarks/CMakeLists.txt @@ -39,7 +39,7 @@ target_link_libraries( storage_benchmarks PUBLIC storage_client_testing google_cloud_cpp_testing - google-cloud-cpp::experimental-storage_grpc + google-cloud-cpp::storage_grpc google-cloud-cpp::storage google-cloud-cpp::grpc_utils google-cloud-cpp::storage_protos @@ -131,6 +131,5 @@ target_compile_features(async_throughput_benchmark PRIVATE cxx_std_20) # `google/cloud/*`. We cannot apply those recommendations because the headers # are also used with C++14. set_target_properties(async_throughput_benchmark PROPERTIES CXX_CLANG_TIDY "") -target_link_libraries( - async_throughput_benchmark - PRIVATE storage_benchmarks google-cloud-cpp::experimental-storage_grpc) +target_link_libraries(async_throughput_benchmark + PRIVATE storage_benchmarks google-cloud-cpp::storage_grpc) diff --git a/google/cloud/storage/benchmarks/aggregate_download_throughput_benchmark.cc b/google/cloud/storage/benchmarks/aggregate_download_throughput_benchmark.cc index 02a447f0bc28c..e32512bdb4e85 100644 --- a/google/cloud/storage/benchmarks/aggregate_download_throughput_benchmark.cc +++ b/google/cloud/storage/benchmarks/aggregate_download_throughput_benchmark.cc @@ -121,10 +121,7 @@ class Iteration { gcs::Client MakeClient(AggregateDownloadThroughputOptions const& options) { auto opts = options.client_options; #if GOOGLE_CLOUD_CPP_STORAGE_HAVE_GRPC - namespace gcs_ex = ::google::cloud::storage_experimental; - if (options.api == "GRPC") { - return gcs_ex::DefaultGrpcClient(std::move(opts)); - } + if (options.api == "GRPC") return gcs::MakeGrpcClient(); #endif // GOOGLE_CLOUD_CPP_STORAGE_HAVE_GRPC return gcs::Client(std::move(opts)); } diff --git a/google/cloud/storage/benchmarks/aggregate_upload_throughput_benchmark.cc b/google/cloud/storage/benchmarks/aggregate_upload_throughput_benchmark.cc index 2cc1ef556f2b2..de45924d6fd9a 100644 --- a/google/cloud/storage/benchmarks/aggregate_upload_throughput_benchmark.cc +++ b/google/cloud/storage/benchmarks/aggregate_upload_throughput_benchmark.cc @@ -114,9 +114,8 @@ gcs::Client MakeClient(AggregateUploadThroughputOptions const& options) { // on almost all `.write()` requests. .set(256 * gcs_bm::kKiB); #if GOOGLE_CLOUD_CPP_STORAGE_HAVE_GRPC - namespace gcs_ex = ::google::cloud::storage_experimental; if (options.api == "GRPC") { - return gcs_ex::DefaultGrpcClient(std::move(opts)); + return gcs::MakeGrpcClient(std::move(opts)); } #endif // GOOGLE_CLOUD_CPP_STORAGE_HAVE_GRPC return gcs::Client(std::move(opts)); diff --git a/google/cloud/storage/benchmarks/async_throughput_benchmark.cc b/google/cloud/storage/benchmarks/async_throughput_benchmark.cc index 8c81981ea3db1..39ec0695f6c05 100644 --- a/google/cloud/storage/benchmarks/async_throughput_benchmark.cc +++ b/google/cloud/storage/benchmarks/async_throughput_benchmark.cc @@ -315,7 +315,7 @@ auto MakeAsyncClients(Configuration const& cfg, auto MakeClient(ClientConfig const& cc, int background_threads) { if (cc.transport == "GRPC") { - return google::cloud::storage_experimental::DefaultGrpcClient( + return gcs::MakeGrpcClient( g::Options{} .set(background_threads) .set(MapPath(cc.path))); diff --git a/google/cloud/storage/benchmarks/storage_throughput_vs_cpu_benchmark.cc b/google/cloud/storage/benchmarks/storage_throughput_vs_cpu_benchmark.cc index 201bebfae41b8..e1ec70ef47e35 100644 --- a/google/cloud/storage/benchmarks/storage_throughput_vs_cpu_benchmark.cc +++ b/google/cloud/storage/benchmarks/storage_throughput_vs_cpu_benchmark.cc @@ -258,16 +258,15 @@ gcs_bm::ClientProvider BaseProvider(ThroughputOptions const& options) { return [=](ExperimentTransport t) { auto opts = options.client_options; #if GOOGLE_CLOUD_CPP_STORAGE_HAVE_GRPC - namespace gcs_ex = ::google::cloud::storage_experimental; if (t == ExperimentTransport::kDirectPath) { opts = google::cloud::internal::MergeOptions(options.direct_path_options, std::move(opts)); - return gcs_ex::DefaultGrpcClient(std::move(opts)); + return gcs::MakeGrpcClient(std::move(opts)); } if (t == ExperimentTransport::kGrpc) { opts = google::cloud::internal::MergeOptions(options.grpc_options, std::move(opts)); - return gcs_ex::DefaultGrpcClient(std::move(opts)); + return gcs::MakeGrpcClient(std::move(opts)); } #else (void)t; // disable unused parameter warning diff --git a/google/cloud/storage/doc/storage-grpc.dox b/google/cloud/storage/doc/storage-grpc.dox index 941986a103fa2..6d9bd6425c1fc 100644 --- a/google/cloud/storage/doc/storage-grpc.dox +++ b/google/cloud/storage/doc/storage-grpc.dox @@ -77,12 +77,12 @@ uses: ```{.cmake} add_executable(quickstart_grpc quickstart_grpc.cc) -target_link_libraries(quickstart_grpc google-cloud-cpp::experimental-storage_grpc) +target_link_libraries(quickstart_grpc google-cloud-cpp::storage_grpc) ``` If you are using Bazel to compile your application, then you need to change the dependencies from `@google_cloud_cpp//:storage` -to `@google_cloud_cpp//:experimental-storage_grpc`. +to `@google_cloud_cpp//:storage_grpc`. For example, our `grpc/quickstart uses: ```{.py} @@ -92,7 +92,7 @@ cc_binary( "quickstart_grpc.cc", ], deps = [ - "@google_cloud_cpp//:experimental-storage_grpc", + "@google_cloud_cpp//:storage_grpc", ], ) ``` diff --git a/google/cloud/storage/examples/BUILD.bazel b/google/cloud/storage/examples/BUILD.bazel index e8dd9398fcb5e..ea41b035da6a5 100644 --- a/google/cloud/storage/examples/BUILD.bazel +++ b/google/cloud/storage/examples/BUILD.bazel @@ -68,9 +68,9 @@ cc_library( deps = [ ":storage_examples_common", "//:common", - "//:experimental-storage_grpc", - "//:experimental-storage_grpc_mocks", "//:storage", + "//:storage_grpc", + "//:storage_grpc_mocks", "//google/cloud/storage:storage_client_testing", "//google/cloud/testing_util:google_cloud_cpp_testing_private", "@com_google_googletest//:gtest_main", @@ -87,8 +87,8 @@ cc_library( deps = [ ":storage_examples_common", "//:common", - "//:experimental-storage_grpc", "//:storage", + "//:storage_grpc", ], ) for test in storage_grpc_examples] @@ -102,8 +102,8 @@ cc_test( deps = [ ":storage_examples_common", "//:common", - "//:experimental-storage_grpc", "//:opentelemetry", "//:storage", + "//:storage_grpc", ], ) diff --git a/google/cloud/storage/examples/CMakeLists.txt b/google/cloud/storage/examples/CMakeLists.txt index b9fbe0d51e435..5f1e4f152a11a 100644 --- a/google/cloud/storage/examples/CMakeLists.txt +++ b/google/cloud/storage/examples/CMakeLists.txt @@ -109,7 +109,7 @@ foreach (fname ${storage_examples_production}) endforeach () # These lists are always defined and exported to Bazel. They are only *used* if -# experimental-storage_grpc is defined. +# storage_grpc is defined. set(storage_grpc_examples # cmake-format: sort storage_async_samples.cc storage_grpc_samples.cc) # The mocking examples take the form of a unit test. @@ -119,7 +119,7 @@ set(storage_grpc_unit_tests # cmake-format: sort export_list_to_bazel("storage_grpc_examples.bzl" "storage_grpc_examples" "storage_grpc_unit_tests" YEAR "2023") -if (NOT "experimental-storage_grpc" IN_LIST GOOGLE_CLOUD_CPP_ENABLE) +if (NOT "storage_grpc" IN_LIST GOOGLE_CLOUD_CPP_ENABLE) return() endif () @@ -128,8 +128,8 @@ foreach (fname ${storage_grpc_unit_tests}) target_link_libraries( ${target} PRIVATE storage_examples_common - google-cloud-cpp::experimental-storage_grpc - google-cloud-cpp::experimental-storage_grpc_mocks + google-cloud-cpp::storage_grpc + google-cloud-cpp::storage_grpc_mocks google-cloud-cpp::storage google-cloud-cpp::common GTest::gmock_main @@ -143,8 +143,7 @@ foreach (fname ${storage_grpc_examples}) google_cloud_cpp_add_executable(target "storage_examples" "${fname}") target_link_libraries( ${target} - PRIVATE storage_examples_common - google-cloud-cpp::experimental-storage_grpc + PRIVATE storage_examples_common google-cloud-cpp::storage_grpc google-cloud-cpp::storage google-cloud-cpp::common) add_test(NAME ${target} COMMAND ${target}) set_tests_properties( @@ -163,8 +162,8 @@ google_cloud_cpp_add_executable(target "storage_examples" target_link_libraries( ${target} PRIVATE storage_examples_common google-cloud-cpp::opentelemetry - google-cloud-cpp::experimental-storage_grpc - google-cloud-cpp::storage google-cloud-cpp::common) + google-cloud-cpp::storage_grpc google-cloud-cpp::storage + google-cloud-cpp::common) add_test(NAME ${target} COMMAND ${target}) set_tests_properties(${target} PROPERTIES LABELS "integration-test") google_cloud_cpp_add_common_options(${target}) diff --git a/google/cloud/storage/examples/storage_grpc_samples.cc b/google/cloud/storage/examples/storage_grpc_samples.cc index ee793ef2f112e..560241bc55714 100644 --- a/google/cloud/storage/examples/storage_grpc_samples.cc +++ b/google/cloud/storage/examples/storage_grpc_samples.cc @@ -36,7 +36,7 @@ void GrpcReadWrite(std::string const& bucket_name) { auto constexpr kText = R"""(Hello World!)"""; //! [grpc-default-client] - auto client = google::cloud::storage_experimental::DefaultGrpcClient(); + auto client = gcs::MakeGrpcClient(); //! [grpc-default-client] auto object = client.InsertObject(bucket_name, "lorem.txt", kText); @@ -59,7 +59,7 @@ void GrpcReadWrite(std::string const& bucket_name) { void GrpcClientWithDP() { namespace g = ::google::cloud; - auto client = google::cloud::storage_experimental::DefaultGrpcClient( + auto client = google::cloud::storage::MakeGrpcClient( g::Options{}.set( "google-c2p:///storage.googleapis.com")); // Use `client` as usual. @@ -68,8 +68,7 @@ void GrpcClientWithDP() { //! [grpc-client-with-project] void GrpcClientWithProject(std::string project_id) { - namespace gcs = ::google::cloud::storage; - auto client = google::cloud::storage_experimental::DefaultGrpcClient( + auto client = google::cloud::storage::MakeGrpcClient( google::cloud::Options{}.set( std::move(project_id))); std::cout << "Successfully created a gcs::Client configured to use gRPC\n"; @@ -112,11 +111,11 @@ void GrpcReportTransportCommand(std::vector argv) { #if GOOGLE_CLOUD_CPP_STORAGE_HAVE_GRPC namespace g = ::google::cloud; if (argv[0] == "GRPC") { - return google::cloud::storage_experimental::DefaultGrpcClient(); + return google::cloud::storage::MakeGrpcClient(); } if (argv[0] == "DP") { // Some documentation calls this `DirectPath` - return google::cloud::storage_experimental::DefaultGrpcClient( + return google::cloud::storage::MakeGrpcClient( g::Options{}.set( "google-c2p:///storage.googleapis.com")); } diff --git a/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake b/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake index 9fe835b59bf9b..17dfb18cf39d3 100644 --- a/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake +++ b/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake @@ -20,7 +20,7 @@ if (NOT GOOGLE_CLOUD_CPP_STORAGE_ENABLE_GRPC) add_library(google_cloud_cpp_storage_grpc INTERFACE) set_target_properties( google_cloud_cpp_storage_grpc - PROPERTIES EXPORT_NAME "google-cloud-cpp::experimental-storage_grpc") + PROPERTIES EXPORT_NAME "google-cloud-cpp::storage_grpc") add_library(google_cloud_cpp_storage_protos INTERFACE) add_library(google-cloud-cpp::storage_protos ALIAS google_cloud_cpp_storage_protos) @@ -219,15 +219,24 @@ else () endif () set_target_properties( google_cloud_cpp_storage_grpc - PROPERTIES EXPORT_NAME "google-cloud-cpp::experimental-storage_grpc" + PROPERTIES EXPORT_NAME "google-cloud-cpp::storage_grpc" VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) create_bazel_config(google_cloud_cpp_storage_grpc) endif () +add_library(google-cloud-cpp::storage_grpc ALIAS google_cloud_cpp_storage_grpc) + +# TODO(#13857) - remove the backwards compatibility shims +add_library(google_cloud_cpp_experimental_storage_grpc INTERFACE) +set_target_properties( + google_cloud_cpp_experimental_storage_grpc + PROPERTIES EXPORT_NAME "google-cloud-cpp::experimental-storage_grpc") +target_link_libraries(google_cloud_cpp_experimental_storage_grpc + INTERFACE google-cloud-cpp::storage_grpc) add_library(google-cloud-cpp::experimental-storage_grpc ALIAS - google_cloud_cpp_storage_grpc) + google_cloud_cpp_experimental_storage_grpc) google_cloud_cpp_add_pkgconfig( storage_grpc @@ -244,6 +253,8 @@ google_cloud_cpp_add_pkgconfig( install( TARGETS google_cloud_cpp_storage_grpc google_cloud_cpp_storage_protos + # TODO(#13857) - remove the backwards compatibility shims + google_cloud_cpp_experimental_storage_grpc EXPORT storage-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT google_cloud_cpp_runtime @@ -270,13 +281,11 @@ if (GOOGLE_CLOUD_CPP_WITH_MOCKS) mocks/mock_async_writer_connection.h) export_list_to_bazel("google_cloud_cpp_storage_grpc_mocks.bzl" "google_cloud_cpp_storage_grpc_mocks_hdrs" YEAR "2023") - target_link_libraries( - google_cloud_cpp_storage_grpc_mocks - INTERFACE google-cloud-cpp::experimental-storage_grpc GTest::gmock) + target_link_libraries(google_cloud_cpp_storage_grpc_mocks + INTERFACE google-cloud-cpp::storage_grpc GTest::gmock) set_target_properties( google_cloud_cpp_storage_grpc_mocks - PROPERTIES EXPORT_NAME - "google-cloud-cpp::experimental-storage_grpc_mocks") + PROPERTIES EXPORT_NAME "google-cloud-cpp::storage_grpc_mocks") target_include_directories( google_cloud_cpp_storage_grpc_mocks INTERFACE $ @@ -284,9 +293,16 @@ if (GOOGLE_CLOUD_CPP_WITH_MOCKS) $) target_compile_options(google_cloud_cpp_storage_grpc_mocks INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG}) - add_library(google-cloud-cpp::experimental-storage_grpc_mocks ALIAS + add_library(google-cloud-cpp::storage_grpc_mocks ALIAS google_cloud_cpp_storage_grpc_mocks) + # TODO(#13857) - remove backwards compatibility shims + add_library(google_cloud_cpp_experimental_storage_grpc_mocks INTERFACE) + target_link_libraries(google_cloud_cpp_experimental_storage_grpc_mocks + INTERFACE google-cloud-cpp::storage_grpc_mocks) + add_library(google-cloud-cpp::experimental-storage_grpc_mocks ALIAS + google_cloud_cpp_experimental_storage_grpc_mocks) + install( FILES ${google_cloud_cpp_storage_grpc_mocks_hdrs} DESTINATION "include/google/cloud/storage/mocks" @@ -300,6 +316,8 @@ if (GOOGLE_CLOUD_CPP_WITH_MOCKS) install( TARGETS google_cloud_cpp_storage_grpc_mocks + # TODO(#13857) - remove backwards compatibility shims + google_cloud_cpp_experimental_storage_grpc_mocks EXPORT storage_grpc_mocks-targets COMPONENT google_cloud_cpp_development) @@ -329,7 +347,7 @@ if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_STORAGE_ENABLE_GRPC) # This is a bit weird, we add an additional link library to # `storage_client_testing` target_link_libraries(storage_client_testing - PUBLIC google-cloud-cpp::experimental-storage_grpc) + PUBLIC google-cloud-cpp::storage_grpc) set(storage_client_grpc_unit_tests # cmake-format: sort @@ -393,8 +411,8 @@ if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_STORAGE_ENABLE_GRPC) PRIVATE storage_client_testing google_cloud_cpp_testing google_cloud_cpp_testing_grpc - google-cloud-cpp::experimental-storage_grpc - google-cloud-cpp::experimental-storage_grpc_mocks + google-cloud-cpp::storage_grpc + google-cloud-cpp::storage_grpc_mocks google-cloud-cpp::storage GTest::gmock_main GTest::gmock diff --git a/google/cloud/storage/grpc_plugin.cc b/google/cloud/storage/grpc_plugin.cc index 14556b72ca68e..d71d1df329d03 100644 --- a/google/cloud/storage/grpc_plugin.cc +++ b/google/cloud/storage/grpc_plugin.cc @@ -22,7 +22,7 @@ namespace google { namespace cloud { -namespace storage_experimental { +namespace storage { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { @@ -39,7 +39,7 @@ bool UseRest(Options const& options) { } // namespace -google::cloud::storage::Client DefaultGrpcClient(Options opts) { +google::cloud::storage::Client MakeGrpcClient(Options opts) { if (UseRest(opts)) return google::cloud::storage::Client(std::move(opts)); opts = google::cloud::storage_internal::DefaultOptionsGrpc(std::move(opts)); auto stub = std::make_unique(opts); @@ -48,6 +48,6 @@ google::cloud::storage::Client DefaultGrpcClient(Options opts) { } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace storage_experimental +} // namespace storage } // namespace cloud } // namespace google diff --git a/google/cloud/storage/grpc_plugin.h b/google/cloud/storage/grpc_plugin.h index 5460cf785992d..bdd9f4e1d81bb 100644 --- a/google/cloud/storage/grpc_plugin.h +++ b/google/cloud/storage/grpc_plugin.h @@ -21,12 +21,30 @@ namespace google { namespace cloud { +namespace storage { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + /** - * Contains experimental features for the GCS C++ Client Library. + * Create a `google::cloud::storage::Client` object configured to use gRPC. + * + * @param opts the configuration parameters for the Client. + * + * @warning At present, GCS gRPC is GA with Allowlist. To access this API, + * kindly contact the Google Cloud Storage gRPC team at + * gcs-grpc-contact@google.com with a list of GCS buckets you would like to + * Allowlist. Please note that while the **service** is GA (with Allowlist), + * the client library features remain experimental and subject to change + * without notice. * - * @warning The types, functions, aliases, and objects in this namespace are - * subject to change without notice. + * @par Example + * @snippet storage_grpc_samples.cc grpc-read-write */ +google::cloud::storage::Client MakeGrpcClient(Options opts = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace storage + +// TODO(#13857) - remove the backwards compatibility shims. namespace storage_experimental { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN @@ -46,19 +64,14 @@ struct [[deprecated( /** * Create a `google::cloud::storage::Client` object configured to use gRPC. * - * @param opts the configuration parameters for the Client. - * - * @warning At present, GCS gRPC is GA with Allowlist. To access this API, - * kindly contact the Google Cloud Storage gRPC team at - * gcs-grpc-contact@google.com with a list of GCS buckets you would like to - * Allowlist. Please note that while the **service** is GA (with Allowlist), - * the client library features remain experimental and subject to change - * without notice. - * - * @par Example - * @snippet storage_grpc_samples.cc grpc-read-write + * @deprecated Please use `google::cloud::storage::MakeGrpcClient`. */ -google::cloud::storage::Client DefaultGrpcClient(Options opts = {}); +[[deprecated( + "use ::google::cloud::storage::MakeGrpcClient() instead")]] inline google:: + cloud::storage::Client + DefaultGrpcClient(Options opts = {}) { + return ::google::cloud::storage::MakeGrpcClient(std::move(opts)); +} GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_experimental diff --git a/google/cloud/storage/grpc_plugin_test.cc b/google/cloud/storage/grpc_plugin_test.cc index bf52e0f675e52..602bd7ab577ef 100644 --- a/google/cloud/storage/grpc_plugin_test.cc +++ b/google/cloud/storage/grpc_plugin_test.cc @@ -43,7 +43,7 @@ TEST(GrpcPluginTest, DefaultCreatesGrpc) { ScopedEnvironment("CLOUD_STORAGE_ENABLE_TRACING", absl::nullopt); auto config = ScopedEnvironment("GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG", absl::nullopt); - auto client = storage_experimental::DefaultGrpcClient(TestOptions()); + auto client = MakeGrpcClient(TestOptions()); auto impl = ClientImplDetails::GetConnection(client); ASSERT_THAT(impl, NotNull()); EXPECT_THAT(impl->InspectStackStructure(), @@ -59,7 +59,7 @@ TEST(GrpcPluginTest, MostConfigValuesCreatesGrpc) { ScopedEnvironment("GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG", absl::nullopt); // Unless the config is set to "none" we want to create the gRPC stub. for (auto const* config : {"", "metadata", "media", "anything-but-none"}) { - auto client = storage_experimental::DefaultGrpcClient( + auto client = MakeGrpcClient( TestOptions().set(config)); auto impl = ClientImplDetails::GetConnection(client); ASSERT_THAT(impl, NotNull()); @@ -74,7 +74,7 @@ TEST(GrpcPluginTest, EnvironmentOverrides) { ScopedEnvironment("CLOUD_STORAGE_ENABLE_TRACING", absl::nullopt); auto config = ScopedEnvironment("GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG", "none"); - auto client = storage_experimental::DefaultGrpcClient( + auto client = MakeGrpcClient( TestOptions().set("metadata")); auto impl = ClientImplDetails::GetConnection(client); ASSERT_THAT(impl, NotNull()); @@ -88,7 +88,7 @@ TEST(GrpcPluginTest, UnsetConfigCreatesMetadata) { ScopedEnvironment("CLOUD_STORAGE_ENABLE_TRACING", absl::nullopt); auto config = ScopedEnvironment("GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG", absl::nullopt); - auto client = storage_experimental::DefaultGrpcClient(TestOptions()); + auto client = MakeGrpcClient(TestOptions()); auto impl = ClientImplDetails::GetConnection(client); ASSERT_THAT(impl, NotNull()); EXPECT_THAT(impl->InspectStackStructure(), @@ -101,7 +101,7 @@ TEST(GrpcPluginTest, NoneConfigCreatesCurl) { ScopedEnvironment("CLOUD_STORAGE_ENABLE_TRACING", absl::nullopt); auto config = ScopedEnvironment("GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG", absl::nullopt); - auto client = storage_experimental::DefaultGrpcClient( + auto client = MakeGrpcClient( TestOptions().set("none")); auto impl = ClientImplDetails::GetConnection(client); ASSERT_THAT(impl, NotNull()); @@ -115,7 +115,7 @@ TEST(GrpcPluginTest, HybridUsesGrpcBufferOptions) { ScopedEnvironment("CLOUD_STORAGE_ENABLE_TRACING", absl::nullopt); auto config = ScopedEnvironment("GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG", absl::nullopt); - auto client = storage_experimental::DefaultGrpcClient( + auto client = MakeGrpcClient( TestOptions().set("media")); EXPECT_GE( client.raw_client()->options().get(), diff --git a/google/cloud/storage/quickstart/BUILD.bazel b/google/cloud/storage/quickstart/BUILD.bazel index d3e5b9e581d77..d7b53ab25f46a 100644 --- a/google/cloud/storage/quickstart/BUILD.bazel +++ b/google/cloud/storage/quickstart/BUILD.bazel @@ -32,7 +32,7 @@ cc_binary( "quickstart_grpc.cc", ], deps = [ - "@google_cloud_cpp//:experimental-storage_grpc", + "@google_cloud_cpp//:storage_grpc", ], ) @@ -42,6 +42,6 @@ cc_binary( "quickstart_async.cc", ], deps = [ - "@google_cloud_cpp//:experimental-storage_grpc", + "@google_cloud_cpp//:storage_grpc", ], ) diff --git a/google/cloud/storage/quickstart/CMakeLists.txt b/google/cloud/storage/quickstart/CMakeLists.txt index 2fefecf1427e0..67c45ccbd13a8 100644 --- a/google/cloud/storage/quickstart/CMakeLists.txt +++ b/google/cloud/storage/quickstart/CMakeLists.txt @@ -31,6 +31,8 @@ endif () add_executable(quickstart quickstart.cc) target_link_libraries(quickstart google-cloud-cpp::storage) +# TODO(#13857) - switch to `google-cloud-cpp::storage_grpc` when the CI builds +# are ready add_executable(quickstart_grpc EXCLUDE_FROM_ALL quickstart_grpc.cc) target_link_libraries(quickstart_grpc google-cloud-cpp::experimental-storage_grpc) diff --git a/google/cloud/storage/quickstart/quickstart.cc b/google/cloud/storage/quickstart/quickstart.cc index 4ca119e270ab3..9b7bca716a505 100644 --- a/google/cloud/storage/quickstart/quickstart.cc +++ b/google/cloud/storage/quickstart/quickstart.cc @@ -24,12 +24,9 @@ int main(int argc, char* argv[]) { } std::string const bucket_name = argv[1]; - // Create aliases to make the code easier to read. - namespace gcs = ::google::cloud::storage; - // Create a client to communicate with Google Cloud Storage. This client // uses the default configuration for authentication and project id. - auto client = gcs::Client(); + auto client = google::cloud::storage::Client(); auto writer = client.WriteObject(bucket_name, "quickstart.txt"); writer << "Hello World!"; diff --git a/google/cloud/storage/quickstart/quickstart_grpc.cc b/google/cloud/storage/quickstart/quickstart_grpc.cc index 416e0a4b91770..edaf6c27eb16a 100644 --- a/google/cloud/storage/quickstart/quickstart_grpc.cc +++ b/google/cloud/storage/quickstart/quickstart_grpc.cc @@ -26,7 +26,7 @@ int main(int argc, char* argv[]) { // Create a client to communicate with Google Cloud Storage. This client // uses the default configuration for authentication and project id. - auto client = google::cloud::storage_experimental::DefaultGrpcClient(); + auto client = google::cloud::storage::MakeGrpcClient(); auto writer = client.WriteObject(bucket_name, "quickstart-grpc.txt"); writer << "Hello World!"; diff --git a/google/cloud/storage/testing/storage_integration_test.cc b/google/cloud/storage/testing/storage_integration_test.cc index ee10b5634afe8..beff82d9e229d 100644 --- a/google/cloud/storage/testing/storage_integration_test.cc +++ b/google/cloud/storage/testing/storage_integration_test.cc @@ -105,7 +105,7 @@ StorageIntegrationTest::MakeIntegrationTestClient( #if GOOGLE_CLOUD_CPP_STORAGE_HAVE_GRPC if (UseGrpcForMedia() || UseGrpcForMetadata()) { - return storage_experimental::DefaultGrpcClient(std::move(opts)); + return MakeGrpcClient(std::move(opts)); } #endif // GOOGLE_CLOUD_CPP_STORAGE_HAVE_GRPC diff --git a/google/cloud/storage/tests/smoke_test_grpc.cc b/google/cloud/storage/tests/smoke_test_grpc.cc index 6746a0293ac46..2873284112e59 100644 --- a/google/cloud/storage/tests/smoke_test_grpc.cc +++ b/google/cloud/storage/tests/smoke_test_grpc.cc @@ -35,7 +35,7 @@ TEST(SmokeTest, Grpc) { GetEnv("GOOGLE_CLOUD_CPP_STORAGE_TEST_BUCKET_NAME").value_or(""); if (bucket_name.empty()) GTEST_SKIP(); - auto client = google::cloud::storage_experimental::DefaultGrpcClient(); + auto client = MakeGrpcClient(); auto gen = google::cloud::internal::MakeDefaultPRNG(); auto object_name = google::cloud::storage::testing::MakeRandomObjectName(gen); diff --git a/google/cloud/storage/tests/unified_credentials_integration_test.cc b/google/cloud/storage/tests/unified_credentials_integration_test.cc index 3c248300b8529..fa2c349186ef5 100644 --- a/google/cloud/storage/tests/unified_credentials_integration_test.cc +++ b/google/cloud/storage/tests/unified_credentials_integration_test.cc @@ -104,10 +104,7 @@ class UnifiedCredentialsIntegrationTest static Client MakeTestClient(Options opts) { std::string const client_type = GetParam(); #if GOOGLE_CLOUD_CPP_STORAGE_HAVE_GRPC - if (client_type == "grpc") { - return google::cloud::storage_experimental::DefaultGrpcClient( - std::move(opts)); - } + if (client_type == "grpc") return MakeGrpcClient(std::move(opts)); #endif // GOOGLE_CLOUD_CPP_STORAGE_HAVE_GRPC return Client(std::move(opts)); } diff --git a/libraries.bzl b/libraries.bzl index bcd1c04532e8f..e4426c3c0389c 100644 --- a/libraries.bzl +++ b/libraries.bzl @@ -22,6 +22,7 @@ GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES = [ ] GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES = [ + "storage_grpc", ] GOOGLE_CLOUD_CPP_GA_LIBRARIES = [