Skip to content

Commit 7eff98e

Browse files
authored
impl(v3): remove backward compatible V1 namespaces (googleapis#15894)
1 parent 36a0a9c commit 7eff98e

78 files changed

Lines changed: 60 additions & 153 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ci/verify_deprecated_targets/verify_deprecated_targets.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,5 @@
1717

1818
int main() {
1919
std::cout << "Hello: " << google::cloud::version_string() << "\n";
20-
// Verifies use of the backward-compatibility aliases: v1 and gcpcxxV1.
21-
std::cout << "Hello: " << google::cloud::v1::version_string() << "\n";
22-
std::cout << "Hello: " << google::cloud::gcpcxxV1::version_string() << "\n";
2320
return 0;
2421
}

doc/v3-migration-guide.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,62 @@ module which can be added to your `MODULE.bazel` file as a dependency.
4444

4545
### Common
4646

47+
<details>
48+
<summary>Removed <code>v1</code> inline namespace alias.
49+
</summary>
50+
51+
The `v1` namespace should be omitted for libraries that are unversioned:
52+
53+
- Bigtable
54+
- PubSub
55+
- Spanner
56+
- Storage
57+
58+
For example, code that used to look like this:
59+
60+
**Before:**
61+
62+
```cpp
63+
64+
google::cloud::v1::pubsub::Publisher publisher;
65+
```
66+
67+
Should be changed to this:
68+
69+
**After:**
70+
71+
```cpp
72+
google::cloud::pubsub::Publisher publisher;
73+
```
74+
75+
</details>
76+
77+
<details>
78+
<summary>Removed <code>gcpcxxV1</code> inline namespace alias.
79+
</summary>
80+
81+
The `gcpcxxV1` namespace should be omitted from versioned libraries. The version
82+
is now part of the service namespace.
83+
84+
For example, code that used to look like this:
85+
86+
**Before:**
87+
88+
```cpp
89+
90+
google::cloud::bigquery_storage_v1::gcpcxxV1::BigQueryReadClient client;
91+
```
92+
93+
Should be changed to this:
94+
95+
**After:**
96+
97+
```cpp
98+
google::cloud::bigquery_storage_v1::BigQueryReadClient client;
99+
```
100+
101+
</details>
102+
47103
<details>
48104
<summary>Removed <code>google::cloud::grpc_utils</code> namespace and headers.
49105
</summary>

generator/generator_config.proto

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ message ServiceConfiguration {
3838

3939
repeated string omitted_services = 8;
4040

41-
// If set to true generate the `gcpxxV1` alias for our inline namespace. Older
42-
// versions of the generated libraries need this, but new libraries should not
43-
// have it.
44-
bool backwards_compatibility_namespace_alias = 9;
45-
4641
// If all rpcs in the service have the same set of retryable status codes,
4742
// typically found in the service_config.json accompanying the proto files,
4843
// generate the ServiceNameRetryTraits struct using the provided codes.

generator/generator_config.textproto

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ service {
481481
forwarding_product_path: "google/cloud/bigquery"
482482
initial_copyright_year: "2021"
483483
omitted_services: ["BigQueryWrite"]
484-
backwards_compatibility_namespace_alias: true
485484
retryable_status_codes: ["kUnavailable"]
486485
omit_streaming_updater: true
487486
}
@@ -2679,7 +2678,6 @@ service {
26792678
product_path: "google/cloud/iam/credentials/v1"
26802679
forwarding_product_path: "google/cloud/iam"
26812680
initial_copyright_year: "2020"
2682-
backwards_compatibility_namespace_alias: true
26832681
retryable_status_codes: ["kUnavailable"]
26842682
idempotency_overrides: [
26852683
{rpc_name: "IAMCredentials.GenerateAccessToken", idempotency: IDEMPOTENT},
@@ -2695,7 +2693,6 @@ service {
26952693
forwarding_product_path: "google/cloud/iam"
26962694
initial_copyright_year: "2021"
26972695
omitted_rpcs: ["SignBlob", "SignJwt", "UpdateServiceAccount"]
2698-
backwards_compatibility_namespace_alias: true
26992696
retryable_status_codes: ["kUnavailable"]
27002697
omitted_rpcs: [
27012698
"SignBlob(std::string const&, std::string const&)",
@@ -3698,7 +3695,6 @@ service {
36983695
initial_copyright_year: "2021"
36993696
service_endpoint_env_var: "GOOGLE_CLOUD_CPP_SPANNER_DEFAULT_ENDPOINT"
37003697
emulator_endpoint_env_var: "SPANNER_EMULATOR_HOST"
3701-
backwards_compatibility_namespace_alias: true
37023698
retryable_status_codes: ["kUnavailable"]
37033699
generate_rest_transport: true
37043700
omit_repo_metadata: true
@@ -3711,7 +3707,6 @@ service {
37113707
initial_copyright_year: "2021"
37123708
service_endpoint_env_var: "GOOGLE_CLOUD_CPP_SPANNER_DEFAULT_ENDPOINT"
37133709
emulator_endpoint_env_var: "SPANNER_EMULATOR_HOST"
3714-
backwards_compatibility_namespace_alias: true
37153710
retryable_status_codes: ["kUnavailable"]
37163711
generate_rest_transport: true
37173712
omit_repo_metadata: true

generator/internal/codegen_utils_test.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,6 @@ TEST(ProcessCommandLineArgs, ProcessArgAsyncOnlyRpc) {
265265
Contains(Pair("gen_async_rpcs", HasSubstr("AsyncOnly"))));
266266
}
267267

268-
TEST(ProcessCommandLineArgs, ProcessArgNamespaceAlias) {
269-
auto result = ProcessCommandLineArgs(
270-
",product_path=google/cloud/spanner/"
271-
",emulator_endpoint_env_var=SPANNER_EMULATOR_HOST"
272-
",backwards_compatibility_namespace_alias=true");
273-
ASSERT_THAT(result, IsOk());
274-
EXPECT_THAT(*result, Contains(Pair("backwards_compatibility_namespace_alias",
275-
HasSubstr("true"))));
276-
}
277-
278268
TEST(ProcessCommandLineArgs, ProcessOmitClient) {
279269
auto result = ProcessCommandLineArgs(
280270
"product_path=google/cloud/spanner/"

generator/internal/make_generators.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ std::vector<std::unique_ptr<GeneratorInterface>> MakeGenerators(
148148
}
149149

150150
if (generate_rest_transport) {
151-
// All REST interfaces postdate the change to the format of our inline
152-
// namespace name, so we never need to add a backwards-compatibility alias.
153151
auto rest_service_vars = service_vars;
154-
rest_service_vars.erase("backwards_compatibility_namespace_alias");
155152
code_generators.push_back(std::make_unique<ConnectionRestGenerator>(
156153
service, rest_service_vars, method_vars, context, mixin_methods));
157154
code_generators.push_back(std::make_unique<ConnectionImplRestGenerator>(

generator/internal/service_code_generator.cc

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ ServiceCodeGenerator::ServiceCodeGenerator(
7272
assert(context != nullptr);
7373
SetVars(service_vars_[header_path_key]);
7474
SetMethods();
75-
auto e = service_vars_.find("backwards_compatibility_namespace_alias");
76-
define_backwards_compatibility_namespace_alias_ =
77-
(e != service_vars_.end() && e->second == "true");
7875
}
7976

8077
ServiceCodeGenerator::ServiceCodeGenerator(
@@ -324,9 +321,7 @@ Status ServiceCodeGenerator::HeaderOpenForwardingNamespaces(
324321
ns_documentation);
325322
}
326323

327-
void ServiceCodeGenerator::HeaderCloseNamespaces() {
328-
CloseNamespaces(header_, define_backwards_compatibility_namespace_alias_);
329-
}
324+
void ServiceCodeGenerator::HeaderCloseNamespaces() { CloseNamespaces(header_); }
330325

331326
Status ServiceCodeGenerator::CcOpenNamespaces(NamespaceType ns_type) {
332327
return OpenNamespaces(cc_, ns_type, "product_path");
@@ -336,7 +331,7 @@ Status ServiceCodeGenerator::CcOpenForwardingNamespaces(NamespaceType ns_type) {
336331
return OpenNamespaces(cc_, ns_type, "forwarding_product_path");
337332
}
338333

339-
void ServiceCodeGenerator::CcCloseNamespaces() { CloseNamespaces(cc_, false); }
334+
void ServiceCodeGenerator::CcCloseNamespaces() { CloseNamespaces(cc_); }
340335

341336
void ServiceCodeGenerator::HeaderPrint(std::string const& text) {
342337
header_.Print(service_vars_, text);
@@ -445,15 +440,9 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
445440
return {};
446441
}
447442

448-
void ServiceCodeGenerator::CloseNamespaces(
449-
Printer& p, bool define_backwards_compatibility_namespace_alias) {
443+
void ServiceCodeGenerator::CloseNamespaces(Printer& p) {
450444
p.Print(R"""(
451445
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END)""");
452-
// TODO(#7463) - remove backwards compatibility namespaces
453-
if (define_backwards_compatibility_namespace_alias) {
454-
p.Print(R"""(
455-
namespace gcpcxxV1 = GOOGLE_CLOUD_CPP_NS; // NOLINT(misc-unused-alias-decls))""");
456-
}
457446
p.Print(R"""(
458447
} // namespace $namespace$
459448
} // namespace cloud

generator/internal/service_code_generator.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,12 @@ class ServiceCodeGenerator : public GeneratorInterface {
259259
Status OpenNamespaces(Printer& p, NamespaceType ns_type,
260260
std::string const& product_path_var,
261261
std::string const& ns_documentation = "");
262-
void CloseNamespaces(Printer& p,
263-
bool define_backwards_compatibility_namespace_alias);
262+
void CloseNamespaces(Printer& p);
264263

265264
google::protobuf::ServiceDescriptor const* service_descriptor_;
266265
VarsDictionary service_vars_;
267266
std::map<std::string, VarsDictionary> service_method_vars_;
268267
std::string namespace_;
269-
bool define_backwards_compatibility_namespace_alias_ = false;
270268
bool pb_h_system_includes_ = false;
271269
MethodDescriptorList methods_;
272270
MethodDescriptorList async_methods_;

generator/standalone_main.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,6 @@ std::vector<std::future<google::cloud::Status>> GenerateCodeFromProtos(
289289
args.emplace_back(absl::StrCat("--cpp_codegen_opt=omit_rpc=",
290290
SafeReplaceAll(omit_rpc, ",", "@")));
291291
}
292-
if (service.backwards_compatibility_namespace_alias()) {
293-
args.emplace_back(
294-
"--cpp_codegen_opt=backwards_compatibility_namespace_alias=true");
295-
}
296292
for (auto const& retry_code : service.retryable_status_codes()) {
297293
args.emplace_back("--cpp_codegen_opt=retry_status_code=" + retry_code);
298294
}

google/cloud/bigquery/storage/v1/bigquery_read_client.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ class BigQueryReadClient {
315315
};
316316

317317
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
318-
namespace gcpcxxV1 = GOOGLE_CLOUD_CPP_NS; // NOLINT(misc-unused-alias-decls)
319318
} // namespace bigquery_storage_v1
320319
} // namespace cloud
321320
} // namespace google

0 commit comments

Comments
 (0)