Skip to content

Commit ed6f7f8

Browse files
roopak-qlogiccoryan
authored andcommitted
Use consistent aliases for proto namespaces (#943)
Fixes #648. Use consistent aliases for namespaces: **only** in the `.cc` files we use aliases for the proto namespaces to save typing. With this PR those aliases have consistent names across files for readability.
1 parent c674ac4 commit ed6f7f8

20 files changed

+266
-290
lines changed

google/cloud/bigtable/benchmarks/embedded_server.cc

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <sstream>
2323

2424
namespace btproto = google::bigtable::v2;
25-
namespace adminproto = google::bigtable::admin::v2;
25+
namespace btadmin = google::bigtable::admin::v2;
2626

2727
namespace google {
2828
namespace cloud {
@@ -73,10 +73,8 @@ class BigtableImpl final : public btproto::Bigtable::Service {
7373
}
7474

7575
grpc::Status ReadRows(
76-
grpc::ServerContext* context,
77-
google::bigtable::v2::ReadRowsRequest const* request,
78-
grpc::ServerWriter<google::bigtable::v2::ReadRowsResponse>* writer)
79-
override {
76+
grpc::ServerContext* context, btproto::ReadRowsRequest const* request,
77+
grpc::ServerWriter<btproto::ReadRowsResponse>* writer) override {
8078
++read_rows_count_;
8179
std::int64_t rows_limit = 10000;
8280
if (request->rows_limit() != 0) {
@@ -133,23 +131,21 @@ class BigtableImpl final : public btproto::Bigtable::Service {
133131
* Implement the `google.bigtable.admin.v2.BigtableTableAdmin` interface for the
134132
* benchmarks.
135133
*/
136-
class TableAdminImpl final : public adminproto::BigtableTableAdmin::Service {
134+
class TableAdminImpl final : public btadmin::BigtableTableAdmin::Service {
137135
public:
138136
TableAdminImpl() : create_table_count_(0), delete_table_count_(0) {}
139137

140-
grpc::Status CreateTable(
141-
grpc::ServerContext* context,
142-
google::bigtable::admin::v2::CreateTableRequest const* request,
143-
google::bigtable::admin::v2::Table* response) override {
138+
grpc::Status CreateTable(grpc::ServerContext* context,
139+
btadmin::CreateTableRequest const* request,
140+
btadmin::Table* response) override {
144141
++create_table_count_;
145142
response->set_name(request->parent() + "/tables/" + request->table_id());
146143
return grpc::Status::OK;
147144
}
148145

149-
grpc::Status DeleteTable(
150-
grpc::ServerContext* context,
151-
google::bigtable::admin::v2::DeleteTableRequest const* request,
152-
::google::protobuf::Empty* response) override {
146+
grpc::Status DeleteTable(grpc::ServerContext* context,
147+
btadmin::DeleteTableRequest const* request,
148+
::google::protobuf::Empty* response) override {
153149
++delete_table_count_;
154150
return grpc::Status::OK;
155151
}

google/cloud/bigtable/examples/bigtable_samples_instance_admin.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
//! [bigtable includes]
2121
#include <google/protobuf/text_format.h>
2222

23-
namespace btproto = ::google::bigtable::admin::v2;
24-
2523
namespace {
2624
struct Usage {
2725
std::string msg;

google/cloud/bigtable/instance_admin.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <google/protobuf/text_format.h>
2121
#include <type_traits>
2222

23-
namespace btproto = ::google::bigtable::admin::v2;
23+
namespace btadmin = ::google::bigtable::admin::v2;
2424

2525
namespace google {
2626
namespace cloud {
@@ -29,7 +29,7 @@ inline namespace BIGTABLE_CLIENT_NS {
2929
static_assert(std::is_copy_assignable<bigtable::InstanceAdmin>::value,
3030
"bigtable::InstanceAdmin must be CopyAssignable");
3131

32-
std::vector<btproto::Instance> InstanceAdmin::ListInstances() {
32+
std::vector<btadmin::Instance> InstanceAdmin::ListInstances() {
3333
grpc::Status status;
3434
auto result = impl_.ListInstances(status);
3535
if (not status.ok()) {
@@ -78,7 +78,7 @@ google::bigtable::admin::v2::Instance InstanceAdmin::CreateInstanceImpl(
7878
"unrecoverable error in MakeCall()");
7979
}
8080

81-
auto result = impl_.PollLongRunningOperation<btproto::Instance>(
81+
auto result = impl_.PollLongRunningOperation<btadmin::Instance>(
8282
operation, "InstanceAdmin::CreateInstance", status);
8383
if (not status.ok()) {
8484
bigtable::internal::RaiseRpcError(
@@ -117,7 +117,7 @@ google::bigtable::admin::v2::Instance InstanceAdmin::UpdateInstanceImpl(
117117
"unrecoverable error in MakeCall()");
118118
}
119119

120-
auto result = impl_.PollLongRunningOperation<btproto::Instance>(
120+
auto result = impl_.PollLongRunningOperation<btadmin::Instance>(
121121
operation, "InstanceAdmin::UpdateInstance", status);
122122
if (not status.ok()) {
123123
bigtable::internal::RaiseRpcError(
@@ -126,7 +126,7 @@ google::bigtable::admin::v2::Instance InstanceAdmin::UpdateInstanceImpl(
126126
return result;
127127
}
128128

129-
btproto::Instance InstanceAdmin::GetInstance(std::string const& instance_id) {
129+
btadmin::Instance InstanceAdmin::GetInstance(std::string const& instance_id) {
130130
grpc::Status status;
131131
auto result = impl_.GetInstance(instance_id, status);
132132
if (not status.ok()) {
@@ -143,7 +143,7 @@ void InstanceAdmin::DeleteInstance(std::string const& instance_id) {
143143
}
144144
}
145145

146-
btproto::Cluster InstanceAdmin::GetCluster(
146+
btadmin::Cluster InstanceAdmin::GetCluster(
147147
bigtable::InstanceId const& instance_id,
148148
bigtable::ClusterId const& cluster_id) {
149149
grpc::Status status;
@@ -154,11 +154,11 @@ btproto::Cluster InstanceAdmin::GetCluster(
154154
return result;
155155
}
156156

157-
std::vector<btproto::Cluster> InstanceAdmin::ListClusters() {
157+
std::vector<btadmin::Cluster> InstanceAdmin::ListClusters() {
158158
return ListClusters("-");
159159
}
160160

161-
std::vector<btproto::Cluster> InstanceAdmin::ListClusters(
161+
std::vector<btadmin::Cluster> InstanceAdmin::ListClusters(
162162
std::string const& instance_id) {
163163
grpc::Status status;
164164
auto result = impl_.ListClusters(instance_id, status);
@@ -198,7 +198,7 @@ google::bigtable::admin::v2::Cluster InstanceAdmin::UpdateClusterImpl(
198198
"unrecoverable error in MakeCall()");
199199
}
200200

201-
auto result = impl_.PollLongRunningOperation<btproto::Cluster>(
201+
auto result = impl_.PollLongRunningOperation<btadmin::Cluster>(
202202
operation, "InstanceAdmin::UpdateCluster", status);
203203
if (not status.ok()) {
204204
bigtable::internal::RaiseRpcError(
@@ -215,7 +215,7 @@ void InstanceAdmin::DeleteCluster(bigtable::InstanceId const& instance_id,
215215
}
216216
}
217217

218-
btproto::AppProfile InstanceAdmin::CreateAppProfile(
218+
btadmin::AppProfile InstanceAdmin::CreateAppProfile(
219219
bigtable::InstanceId const& instance_id, AppProfileConfig config) {
220220
grpc::Status status;
221221
auto result = impl_.CreateAppProfile(instance_id, std::move(config), status);
@@ -225,7 +225,7 @@ btproto::AppProfile InstanceAdmin::CreateAppProfile(
225225
return result;
226226
}
227227

228-
btproto::AppProfile InstanceAdmin::GetAppProfile(
228+
btadmin::AppProfile InstanceAdmin::GetAppProfile(
229229
bigtable::InstanceId const& instance_id,
230230
bigtable::AppProfileId const& profile_id) {
231231
grpc::Status status;
@@ -236,15 +236,15 @@ btproto::AppProfile InstanceAdmin::GetAppProfile(
236236
return result;
237237
}
238238

239-
std::future<btproto::AppProfile> InstanceAdmin::UpdateAppProfile(
239+
std::future<btadmin::AppProfile> InstanceAdmin::UpdateAppProfile(
240240
bigtable::InstanceId instance_id, bigtable::AppProfileId profile_id,
241241
AppProfileUpdateConfig config) {
242242
return std::async(std::launch::async, &InstanceAdmin::UpdateAppProfileImpl,
243243
this, std::move(instance_id), std::move(profile_id),
244244
std::move(config));
245245
}
246246

247-
std::vector<btproto::AppProfile> InstanceAdmin::ListAppProfiles(
247+
std::vector<btadmin::AppProfile> InstanceAdmin::ListAppProfiles(
248248
std::string const& instance_id) {
249249
grpc::Status status;
250250
auto result = impl_.ListAppProfiles(instance_id, status);
@@ -276,7 +276,7 @@ google::bigtable::admin::v2::Cluster InstanceAdmin::CreateClusterImpl(
276276
auto cluster = cluster_config.as_proto_move();
277277
cluster.set_location(project_name() + "/locations/" + cluster.location());
278278

279-
btproto::CreateClusterRequest request;
279+
btadmin::CreateClusterRequest request;
280280
request.mutable_cluster()->Swap(&cluster);
281281
request.set_parent(project_name() + "/instances/" + instance_id.get());
282282
request.set_cluster_id(cluster_id.get());
@@ -294,7 +294,7 @@ google::bigtable::admin::v2::Cluster InstanceAdmin::CreateClusterImpl(
294294
"unrecoverable error in MakeCall()");
295295
}
296296

297-
auto result = impl_.PollLongRunningOperation<btproto::Cluster>(
297+
auto result = impl_.PollLongRunningOperation<btadmin::Cluster>(
298298
operation, "InstanceAdmin::CreateCluster", status);
299299
if (not status.ok()) {
300300
bigtable::internal::RaiseRpcError(
@@ -303,7 +303,7 @@ google::bigtable::admin::v2::Cluster InstanceAdmin::CreateClusterImpl(
303303
return result;
304304
}
305305

306-
btproto::AppProfile InstanceAdmin::UpdateAppProfileImpl(
306+
btadmin::AppProfile InstanceAdmin::UpdateAppProfileImpl(
307307
bigtable::InstanceId instance_id, bigtable::AppProfileId profile_id,
308308
AppProfileUpdateConfig config) {
309309
grpc::Status status;
@@ -313,7 +313,7 @@ btproto::AppProfile InstanceAdmin::UpdateAppProfileImpl(
313313
internal::RaiseRpcError(status, status.error_message());
314314
}
315315

316-
auto result = impl_.PollLongRunningOperation<btproto::AppProfile>(
316+
auto result = impl_.PollLongRunningOperation<btadmin::AppProfile>(
317317
operation, "InstanceAdmin::UpdateAppProfileImpl", status);
318318
if (not status.ok()) {
319319
internal::RaiseRpcError(status, status.error_message());

0 commit comments

Comments
 (0)