|
15 | 15 | #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_DYNAMIC_CHANNEL_POOL_H |
16 | 16 | #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_DYNAMIC_CHANNEL_POOL_H |
17 | 17 |
|
| 18 | +#include "google/cloud/bigtable/internal/connection_refresh_state.h" |
18 | 19 | #include "google/cloud/completion_queue.h" |
19 | 20 | #include "google/cloud/internal/random.h" |
20 | 21 | #include "google/cloud/version.h" |
@@ -98,24 +99,28 @@ class DynamicChannelPool |
98 | 99 |
|
99 | 100 | static std::shared_ptr<DynamicChannelPool> Create( |
100 | 101 | CompletionQueue cq, std::size_t initial_size, |
101 | | - StubFactoryFn stub_factory_fn, SizingPolicy sizing_policy = {}) { |
| 102 | + StubFactoryFn stub_factory_fn, |
| 103 | + std::shared_ptr<ConnectionRefreshState> refresh_state, |
| 104 | + SizingPolicy sizing_policy = {}) { |
102 | 105 | std::cout << __PRETTY_FUNCTION__ << std::endl; |
103 | 106 | std::vector<std::shared_ptr<StubUsageWrapper<T>>> initial_wrapped_channels; |
104 | 107 | for (std::size_t i = 0; i < initial_size; ++i) { |
105 | 108 | initial_wrapped_channels.emplace_back(stub_factory_fn()); |
106 | 109 | } |
107 | 110 | auto pool = std::shared_ptr<DynamicChannelPool>(new DynamicChannelPool( |
108 | 111 | std::move(cq), std::move(initial_wrapped_channels), |
109 | | - std::move(stub_factory_fn), std::move(sizing_policy))); |
| 112 | + std::move(refresh_state), std::move(stub_factory_fn), |
| 113 | + std::move(sizing_policy))); |
110 | 114 | } |
111 | 115 |
|
112 | 116 | static std::shared_ptr<DynamicChannelPool> Create( |
113 | 117 | CompletionQueue cq, std::vector<std::shared_ptr<T>> initial_channels, |
| 118 | + std::shared_ptr<ConnectionRefreshState> refresh_state, |
114 | 119 | StubFactoryFn stub_factory_fn, SizingPolicy sizing_policy = {}) { |
115 | 120 | std::cout << __PRETTY_FUNCTION__ << std::endl; |
116 | 121 | auto pool = std::shared_ptr<DynamicChannelPool>(new DynamicChannelPool( |
117 | | - std::move(cq), std::move(initial_channels), std::move(stub_factory_fn), |
118 | | - std::move(sizing_policy))); |
| 122 | + std::move(cq), std::move(initial_channels), std::move(refresh_state), |
| 123 | + std::move(stub_factory_fn), std::move(sizing_policy))); |
119 | 124 | return pool; |
120 | 125 | } |
121 | 126 |
|
@@ -166,17 +171,21 @@ class DynamicChannelPool |
166 | 171 | DynamicChannelPool(CompletionQueue cq, |
167 | 172 | std::vector<std::shared_ptr<StubUsageWrapper<T>>> |
168 | 173 | initial_wrapped_channels, |
| 174 | + std::shared_ptr<ConnectionRefreshState> refresh_state, |
169 | 175 | StubFactoryFn stub_factory_fn, SizingPolicy sizing_policy) |
170 | 176 | : cq_(std::move(cq)), |
| 177 | + refresh_state_(std::move(refresh_state)), |
171 | 178 | stub_factory_fn_(std::move(stub_factory_fn)), |
172 | 179 | channels_(std::move(initial_wrapped_channels)), |
173 | 180 | sizing_policy_(std::move(sizing_policy)), |
174 | 181 | next_channel_id_(channels_.size()) {} |
175 | 182 |
|
176 | 183 | DynamicChannelPool(CompletionQueue cq, |
177 | 184 | std::vector<std::shared_ptr<T>> initial_channels, |
| 185 | + std::shared_ptr<ConnectionRefreshState> refresh_state, |
178 | 186 | StubFactoryFn stub_factory_fn, SizingPolicy sizing_policy) |
179 | 187 | : cq_(std::move(cq)), |
| 188 | + refresh_state_(std::move(refresh_state)), |
180 | 189 | stub_factory_fn_(std::move(stub_factory_fn)), |
181 | 190 | channels_(), |
182 | 191 | sizing_policy_(std::move(sizing_policy)), |
@@ -299,6 +308,7 @@ class DynamicChannelPool |
299 | 308 | mutable std::mutex mu_; |
300 | 309 | CompletionQueue cq_; |
301 | 310 | google::cloud::internal::DefaultPRNG rng_; |
| 311 | + std::shared_ptr<ConnectionRefreshState> refresh_state_; |
302 | 312 | StubFactoryFn stub_factory_fn_; |
303 | 313 | std::vector<std::shared_ptr<StubUsageWrapper<T>>> channels_; |
304 | 314 | SizingPolicy sizing_policy_; |
|
0 commit comments