Skip to content

Commit 271fba3

Browse files
authored
refactor(bigtable)!: mark InstanceAdminClient as final (#8449)
1 parent 291e9dd commit 271fba3

File tree

4 files changed

+21
-31
lines changed

4 files changed

+21
-31
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ The library has been expanded to include the following services:
108108

109109
### [Bigtable](https://github.com/googleapis/google-cloud-cpp/blob/main/google/cloud/bigtable/README.md)
110110

111-
**BREAKING CHANGE:** The `bigtable::TableAdminClient` interface has changed
111+
**BREAKING CHANGE:** The `bigtable::AdminClient` interface has changed
112112
significantly. Any code that extends this class or calls its experimental public
113113
APIs (`reset()`, `Channel()`) will be broken. For the most part, this should
114114
only affect customers who mock this class in their tests. Code that calls
@@ -140,6 +140,10 @@ information on these new classes, see our [Architecture Design] document.
140140
Again, we apologize for making this breaking change, but we believe it is in the
141141
best long-term interest of our customers.
142142

143+
**BREAKING CHANGE:** The `bigtable::InstanceAdminClient` class has been marked
144+
as `final`. After the changes in [v1.36.0](#v1360---2022-02), there is no need
145+
or reason to be extending this class.
146+
143147
### New Libraries
144148

145149
<!-- TODO: update library count with next release -->

google/cloud/bigtable/instance_admin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class InstanceAdmin {
153153
*/
154154
// NOLINTNEXTLINE(performance-unnecessary-value-param)
155155
explicit InstanceAdmin(std::shared_ptr<InstanceAdminClient> client)
156-
: InstanceAdmin(client->connection(), client->project()) {}
156+
: InstanceAdmin(client->connection_, client->project()) {}
157157

158158
/**
159159
* Create a new InstanceAdmin using explicit policies to handle RPC errors.
@@ -182,7 +182,7 @@ class InstanceAdmin {
182182
// NOLINTNEXTLINE(performance-unnecessary-value-param)
183183
explicit InstanceAdmin(std::shared_ptr<InstanceAdminClient> client,
184184
Policies&&... policies)
185-
: connection_(client->connection()),
185+
: connection_(client->connection_),
186186
project_id_(client->project()),
187187
project_name_(Project(project_id_).FullName()),
188188
retry_prototype_(

google/cloud/bigtable/instance_admin_client.cc

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,12 @@ namespace google {
1919
namespace cloud {
2020
namespace bigtable {
2121
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
22-
namespace {
23-
24-
class DefaultInstanceAdminClient : public InstanceAdminClient {
25-
public:
26-
DefaultInstanceAdminClient(std::string project, Options options)
27-
: project_(std::move(project)),
28-
connection_(bigtable_admin::MakeBigtableInstanceAdminConnection(
29-
std::move(options))) {}
30-
31-
std::string const& project() const override { return project_; }
32-
33-
private:
34-
std::shared_ptr<bigtable_admin::BigtableInstanceAdminConnection> connection()
35-
override {
36-
return connection_;
37-
}
38-
39-
std::string project_;
40-
std::shared_ptr<bigtable_admin::BigtableInstanceAdminConnection> connection_;
41-
};
42-
43-
} // anonymous namespace
4422

4523
std::shared_ptr<InstanceAdminClient> MakeInstanceAdminClient(
4624
std::string project, Options options) {
4725
options = internal::DefaultInstanceAdminOptions(std::move(options));
48-
return std::make_shared<DefaultInstanceAdminClient>(std::move(project),
49-
std::move(options));
26+
return std::shared_ptr<InstanceAdminClient>(
27+
new InstanceAdminClient(std::move(project), std::move(options)));
5028
}
5129

5230
std::shared_ptr<InstanceAdminClient> CreateDefaultInstanceAdminClient(

google/cloud/bigtable/instance_admin_client.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,25 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
3737
* configure `bigtable_admin::BigtableInstanceAdminClient`, instead of using
3838
* this class to configure `bigtable::InstanceAdmin`.
3939
*/
40-
class InstanceAdminClient {
40+
class InstanceAdminClient final {
4141
public:
4242
virtual ~InstanceAdminClient() = default;
4343

4444
/// The project id that this AdminClient works on.
45-
virtual std::string const& project() const = 0;
45+
virtual std::string const& project() { return project_; }
4646

4747
private:
4848
friend class InstanceAdmin;
49-
virtual std::shared_ptr<bigtable_admin::BigtableInstanceAdminConnection>
50-
connection() = 0;
49+
friend std::shared_ptr<InstanceAdminClient> MakeInstanceAdminClient(
50+
std::string, Options);
51+
52+
InstanceAdminClient(std::string project, Options options)
53+
: project_(std::move(project)),
54+
connection_(bigtable_admin::MakeBigtableInstanceAdminConnection(
55+
std::move(options))) {}
56+
57+
std::string project_;
58+
std::shared_ptr<bigtable_admin::BigtableInstanceAdminConnection> connection_;
5159
};
5260

5361
/// Create a new instance admin client configured via @p options.

0 commit comments

Comments
 (0)