blob: 200e477822c40c8ff3dbd6a1723b756e948543c8 [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015-2016 gRPC authors.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080016 *
17 */
18
19#include <grpc++/server_builder.h>
20
Craig Tiller14a65f92015-02-09 13:13:14 -080021#include <grpc++/impl/service_type.h>
Craig Tillerafcc8752016-10-18 16:10:06 -070022#include <grpc++/resource_quota.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080023#include <grpc++/server.h>
Craig Tillerf40df232016-03-25 13:38:14 -070024#include <grpc/support/cpu.h>
25#include <grpc/support/log.h>
David Garcia Quintas468e16d2016-08-31 13:29:40 +020026#include <grpc/support/useful.h>
David Garcia Quintas2d024562016-05-17 23:24:39 -070027
Vijay Paie8a7e302015-08-24 10:52:33 -070028#include "src/cpp/server/thread_pool_interface.h"
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080029
30namespace grpc {
31
Yuchen Zeng7d099a52016-05-06 13:21:36 -070032static std::vector<std::unique_ptr<ServerBuilderPlugin> (*)()>*
33 g_plugin_factory_list;
Yuchen Zeng3b8f3352016-05-03 12:18:13 -070034static gpr_once once_init_plugin_list = GPR_ONCE_INIT;
35
36static void do_plugin_list_init(void) {
Yuchen Zeng7d099a52016-05-06 13:21:36 -070037 g_plugin_factory_list =
38 new std::vector<std::unique_ptr<ServerBuilderPlugin> (*)()>();
Yuchen Zeng3b8f3352016-05-03 12:18:13 -070039}
40
Yang Gao5f4539f2015-03-06 16:11:16 -080041ServerBuilder::ServerBuilder()
Mark D. Roth69803622016-09-06 08:15:36 -070042 : max_receive_message_size_(-1),
43 max_send_message_size_(-1),
Sree Kuchibhotla96766192016-10-13 12:42:54 -070044 sync_server_settings_(SyncServerSettings()),
Craig Tiller20afa3d2016-10-17 14:52:14 -070045 resource_quota_(nullptr),
Mark D. Roth69803622016-09-06 08:15:36 -070046 generic_service_(nullptr) {
Yuchen Zeng3b8f3352016-05-03 12:18:13 -070047 gpr_once_init(&once_init_plugin_list, do_plugin_list_init);
Vijay Paieac07c32016-06-10 01:36:53 -070048 for (auto it = g_plugin_factory_list->begin();
49 it != g_plugin_factory_list->end(); it++) {
Vijay Paib645a2d2016-06-09 18:39:06 -070050 auto& factory = *it;
Vijay Pai15855f32016-06-10 12:25:32 -070051 plugins_.emplace_back(factory());
Yuchen Zeng3b8f3352016-05-03 12:18:13 -070052 }
Sree Kuchibhotla892dbf42016-09-27 19:42:27 -070053
David Garcia Quintas2d024562016-05-17 23:24:39 -070054 // all compression algorithms enabled by default.
55 enabled_compression_algorithms_bitset_ =
56 (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
57 memset(&maybe_default_compression_level_, 0,
58 sizeof(maybe_default_compression_level_));
59 memset(&maybe_default_compression_algorithm_, 0,
60 sizeof(maybe_default_compression_algorithm_));
David Garcia Quintasbeac88c2015-08-10 13:39:52 -070061}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080062
Craig Tillerdb1a5cc2016-09-28 14:22:12 -070063ServerBuilder::~ServerBuilder() {
Craig Tiller20afa3d2016-10-17 14:52:14 -070064 if (resource_quota_ != nullptr) {
65 grpc_resource_quota_unref(resource_quota_);
Craig Tillerdb1a5cc2016-09-28 14:22:12 -070066 }
67}
68
Sree Kuchibhotla1f5e2622016-04-21 12:28:09 -070069std::unique_ptr<ServerCompletionQueue> ServerBuilder::AddCompletionQueue(
70 bool is_frequently_polled) {
Craig Tiller334c4672017-04-11 16:26:07 -070071 ServerCompletionQueue* cq = new ServerCompletionQueue(
72 is_frequently_polled ? GRPC_CQ_DEFAULT_POLLING : GRPC_CQ_NON_LISTENING);
Craig Tillerf9e6adf2015-05-06 11:45:59 -070073 cqs_.push_back(cq);
74 return std::unique_ptr<ServerCompletionQueue>(cq);
75}
76
David Garcia Quintas2d024562016-05-17 23:24:39 -070077ServerBuilder& ServerBuilder::RegisterService(Service* service) {
Craig Tiller15f383c2016-01-07 12:45:32 -080078 services_.emplace_back(new NamedService(service));
David Garcia Quintas2d024562016-05-17 23:24:39 -070079 return *this;
Craig Tiller822d2c72015-07-07 16:08:00 -070080}
81
David Garcia Quintas2d024562016-05-17 23:24:39 -070082ServerBuilder& ServerBuilder::RegisterService(const grpc::string& addr,
83 Service* service) {
Craig Tiller15f383c2016-01-07 12:45:32 -080084 services_.emplace_back(new NamedService(addr, service));
David Garcia Quintas2d024562016-05-17 23:24:39 -070085 return *this;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080086}
87
David Garcia Quintas2d024562016-05-17 23:24:39 -070088ServerBuilder& ServerBuilder::RegisterAsyncGenericService(
89 AsyncGenericService* service) {
Yang Gao005eb882015-03-11 22:17:13 -070090 if (generic_service_) {
Yang Gao1c402332015-03-05 16:39:25 -080091 gpr_log(GPR_ERROR,
Yang Gao49996492015-03-12 16:40:19 -070092 "Adding multiple AsyncGenericService is unsupported for now. "
Yang Gao6baa9b62015-03-17 10:49:39 -070093 "Dropping the service %p",
Sree Kuchibhotla4028d2c2016-09-21 10:45:33 -070094 (void*)service);
David Garcia Quintas2d024562016-05-17 23:24:39 -070095 } else {
96 generic_service_ = service;
Yang Gao1c402332015-03-05 16:39:25 -080097 }
David Garcia Quintas2d024562016-05-17 23:24:39 -070098 return *this;
Yang Gao1c402332015-03-05 16:39:25 -080099}
100
David Garcia Quintas2d024562016-05-17 23:24:39 -0700101ServerBuilder& ServerBuilder::SetOption(
102 std::unique_ptr<ServerBuilderOption> option) {
yang-ga23f17b2015-11-25 10:21:05 -0800103 options_.push_back(std::move(option));
David Garcia Quintas2d024562016-05-17 23:24:39 -0700104 return *this;
yang-ga23f17b2015-11-25 10:21:05 -0800105}
106
Sree Kuchibhotla96766192016-10-13 12:42:54 -0700107ServerBuilder& ServerBuilder::SetSyncServerOption(
108 ServerBuilder::SyncServerOption option, int val) {
109 switch (option) {
110 case NUM_CQS:
111 sync_server_settings_.num_cqs = val;
112 break;
Sree Kuchibhotla96766192016-10-13 12:42:54 -0700113 case MIN_POLLERS:
114 sync_server_settings_.min_pollers = val;
115 break;
116 case MAX_POLLERS:
117 sync_server_settings_.max_pollers = val;
118 break;
119 case CQ_TIMEOUT_MSEC:
120 sync_server_settings_.cq_timeout_msec = val;
121 break;
122 }
123 return *this;
124}
125
David Garcia Quintas2d024562016-05-17 23:24:39 -0700126ServerBuilder& ServerBuilder::SetCompressionAlgorithmSupportStatus(
127 grpc_compression_algorithm algorithm, bool enabled) {
128 if (enabled) {
129 GPR_BITSET(&enabled_compression_algorithms_bitset_, algorithm);
130 } else {
131 GPR_BITCLEAR(&enabled_compression_algorithms_bitset_, algorithm);
132 }
133 return *this;
134}
135
136ServerBuilder& ServerBuilder::SetDefaultCompressionLevel(
137 grpc_compression_level level) {
138 maybe_default_compression_level_.level = level;
139 return *this;
140}
141
142ServerBuilder& ServerBuilder::SetDefaultCompressionAlgorithm(
143 grpc_compression_algorithm algorithm) {
144 maybe_default_compression_algorithm_.is_set = true;
145 maybe_default_compression_algorithm_.algorithm = algorithm;
146 return *this;
147}
148
Craig Tiller20afa3d2016-10-17 14:52:14 -0700149ServerBuilder& ServerBuilder::SetResourceQuota(
150 const grpc::ResourceQuota& resource_quota) {
151 if (resource_quota_ != nullptr) {
152 grpc_resource_quota_unref(resource_quota_);
Craig Tillerdb1a5cc2016-09-28 14:22:12 -0700153 }
Craig Tiller20afa3d2016-10-17 14:52:14 -0700154 resource_quota_ = resource_quota.c_resource_quota();
155 grpc_resource_quota_ref(resource_quota_);
Craig Tillerdb1a5cc2016-09-28 14:22:12 -0700156 return *this;
157}
158
David Garcia Quintas2d024562016-05-17 23:24:39 -0700159ServerBuilder& ServerBuilder::AddListeningPort(
David Garcia Quintas94ab1b52017-05-15 15:27:11 -0700160 const grpc::string& addr_uri, std::shared_ptr<ServerCredentials> creds,
David Garcia Quintas2d024562016-05-17 23:24:39 -0700161 int* selected_port) {
David Garcia Quintas94ab1b52017-05-15 15:27:11 -0700162 const grpc::string uri_scheme = "dns:";
163 grpc::string addr = addr_uri;
164 if (addr_uri.compare(0, uri_scheme.size(), uri_scheme) == 0) {
165 size_t pos = uri_scheme.size();
166 while (addr_uri[pos] == '/') ++pos; // Skip slashes.
167 addr = addr_uri.substr(pos);
168 }
Nicolas Noble30862032015-04-24 18:17:45 -0700169 Port port = {addr, creds, selected_port};
170 ports_.push_back(port);
David Garcia Quintas2d024562016-05-17 23:24:39 -0700171 return *this;
yangg9e21f722014-12-08 15:49:52 -0800172}
173
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800174std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
yang-g21035da2017-05-16 11:42:04 -0700175 for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
176 (*plugin)->UpdateServerBuilder(this);
177 }
178
Sree Kuchibhotla2d08f5b2016-09-26 16:11:02 -0700179 ChannelArguments args;
180 for (auto option = options_.begin(); option != options_.end(); ++option) {
181 (*option)->UpdateArguments(&args);
182 (*option)->UpdatePlugins(&plugins_);
183 }
184
185 for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
186 (*plugin)->UpdateChannelArguments(&args);
187 }
188
189 if (max_receive_message_size_ >= 0) {
190 args.SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, max_receive_message_size_);
191 }
192
193 if (max_send_message_size_ >= 0) {
194 args.SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, max_send_message_size_);
195 }
196
197 args.SetInt(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
198 enabled_compression_algorithms_bitset_);
199 if (maybe_default_compression_level_.is_set) {
200 args.SetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL,
201 maybe_default_compression_level_.level);
202 }
203 if (maybe_default_compression_algorithm_.is_set) {
204 args.SetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM,
205 maybe_default_compression_algorithm_.algorithm);
206 }
207
Craig Tiller20afa3d2016-10-17 14:52:14 -0700208 if (resource_quota_ != nullptr) {
Craig Tiller153eaa72016-10-21 13:52:36 -0700209 args.SetPointerWithVtable(GRPC_ARG_RESOURCE_QUOTA, resource_quota_,
Craig Tiller20afa3d2016-10-17 14:52:14 -0700210 grpc_resource_quota_arg_vtable());
Craig Tillerdb1a5cc2016-09-28 14:22:12 -0700211 }
Sree Kuchibhotla1e088b42016-10-28 17:34:55 -0700212
Sree Kuchibhotla3ea9e242016-08-22 14:15:43 -0700213 // == Determine if the server has any syncrhonous methods ==
Craig Tiller8a7fe1a2016-05-20 11:17:20 -0700214 bool has_sync_methods = false;
Craig Tiller15f383c2016-01-07 12:45:32 -0800215 for (auto it = services_.begin(); it != services_.end(); ++it) {
216 if ((*it)->service->has_synchronous_methods()) {
Sree Kuchibhotla3ea9e242016-08-22 14:15:43 -0700217 has_sync_methods = true;
218 break;
219 }
220 }
221
222 if (!has_sync_methods) {
223 for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
224 if ((*plugin)->has_sync_methods()) {
Craig Tiller8a7fe1a2016-05-20 11:17:20 -0700225 has_sync_methods = true;
yang-gbef0d872016-01-13 15:27:33 -0800226 break;
Craig Tiller15f383c2016-01-07 12:45:32 -0800227 }
228 }
Craig Tiller0db1bef2015-02-09 13:47:39 -0800229 }
Sree Kuchibhotla3ea9e242016-08-22 14:15:43 -0700230
Sree Kuchibhotlaaabada92016-08-24 10:01:13 -0700231 // If this is a Sync server, i.e a server expositing sync API, then the server
232 // needs to create some completion queues to listen for incoming requests.
233 // 'sync_server_cqs' are those internal completion queues.
234 //
235 // This is different from the completion queues added to the server via
236 // ServerBuilder's AddCompletionQueue() method (those completion queues
237 // are in 'cqs_' member variable of ServerBuilder object)
Sree Kuchibhotla4028d2c2016-09-21 10:45:33 -0700238 std::shared_ptr<std::vector<std::unique_ptr<ServerCompletionQueue>>>
Sree Kuchibhotla61355352016-10-20 11:17:22 -0700239 sync_server_cqs(std::make_shared<
240 std::vector<std::unique_ptr<ServerCompletionQueue>>>());
Sree Kuchibhotlaaabada92016-08-24 10:01:13 -0700241
Craig Tiller75bfb972017-04-11 17:55:12 -0700242 int num_frequently_polled_cqs = 0;
243 for (auto it = cqs_.begin(); it != cqs_.end(); ++it) {
244 if ((*it)->IsFrequentlyPolled()) {
245 num_frequently_polled_cqs++;
246 }
247 }
248
249 const bool is_hybrid_server =
250 has_sync_methods && num_frequently_polled_cqs > 0;
251
Sree Kuchibhotlaaabada92016-08-24 10:01:13 -0700252 if (has_sync_methods) {
Craig Tiller334c4672017-04-11 16:26:07 -0700253 grpc_cq_polling_type polling_type =
Craig Tiller75bfb972017-04-11 17:55:12 -0700254 is_hybrid_server ? GRPC_CQ_NON_POLLING : GRPC_CQ_DEFAULT_POLLING;
Craig Tiller334c4672017-04-11 16:26:07 -0700255
Sree Kuchibhotlaa7a21d22016-09-28 12:38:01 -0700256 // Create completion queues to listen to incoming rpc requests
Sree Kuchibhotla892dbf42016-09-27 19:42:27 -0700257 for (int i = 0; i < sync_server_settings_.num_cqs; i++) {
Craig Tiller334c4672017-04-11 16:26:07 -0700258 sync_server_cqs->emplace_back(new ServerCompletionQueue(polling_type));
Sree Kuchibhotlaaabada92016-08-24 10:01:13 -0700259 }
260 }
261
Sree Kuchibhotla892dbf42016-09-27 19:42:27 -0700262 std::unique_ptr<Server> server(new Server(
Sree Kuchibhotlae4eb51f2016-10-18 11:51:28 -0700263 max_receive_message_size_, &args, sync_server_cqs,
Sree Kuchibhotla892dbf42016-09-27 19:42:27 -0700264 sync_server_settings_.min_pollers, sync_server_settings_.max_pollers,
265 sync_server_settings_.cq_timeout_msec));
Sree Kuchibhotla3ea9e242016-08-22 14:15:43 -0700266
ncteisen85fac6d2017-07-12 07:49:45 -0700267 if (has_sync_methods) {
268 // This is a Sync server
269 gpr_log(GPR_INFO,
270 "Synchronous server. Num CQs: %d, Min pollers: %d, Max Pollers: "
271 "%d, CQ timeout (msec): %d",
272 sync_server_settings_.num_cqs, sync_server_settings_.min_pollers,
273 sync_server_settings_.max_pollers,
274 sync_server_settings_.cq_timeout_msec);
275 }
276
Yuchen Zenga42ec212016-04-29 13:03:06 -0700277 ServerInitializer* initializer = server->initializer();
Sree Kuchibhotla7def0362016-04-21 14:54:32 -0700278
Sree Kuchibhotlaaabada92016-08-24 10:01:13 -0700279 // Register all the completion queues with the server. i.e
280 // 1. sync_server_cqs: internal completion queues created IF this is a sync
281 // server
282 // 2. cqs_: Completion queues added via AddCompletionQueue() call
Sree Kuchibhotla7def0362016-04-21 14:54:32 -0700283
Sree Kuchibhotlaaabada92016-08-24 10:01:13 -0700284 for (auto it = sync_server_cqs->begin(); it != sync_server_cqs->end(); ++it) {
Craig Tiller11c58322017-04-12 08:21:17 -0700285 grpc_server_register_completion_queue(server->server_, (*it)->cq(),
286 nullptr);
Craig Tiller75bfb972017-04-11 17:55:12 -0700287 num_frequently_polled_cqs++;
Sree Kuchibhotlaaabada92016-08-24 10:01:13 -0700288 }
289
290 // cqs_ contains the completion queue added by calling the ServerBuilder's
291 // AddCompletionQueue() API. Some of them may not be frequently polled (i.e by
292 // calling Next() or AsyncNext()) and hence are not safe to be used for
293 // listening to incoming channels. Such completion queues must be registered
294 // as non-listening queues
295 for (auto it = cqs_.begin(); it != cqs_.end(); ++it) {
Craig Tiller11c58322017-04-12 08:21:17 -0700296 grpc_server_register_completion_queue(server->server_, (*it)->cq(),
297 nullptr);
Craig Tillerf9e6adf2015-05-06 11:45:59 -0700298 }
Sree Kuchibhotla7def0362016-04-21 14:54:32 -0700299
300 if (num_frequently_polled_cqs == 0) {
301 gpr_log(GPR_ERROR,
Craig Tilleraae6c2c2016-05-20 08:58:30 -0700302 "At least one of the completion queues must be frequently polled");
Sree Kuchibhotla7def0362016-04-21 14:54:32 -0700303 return nullptr;
304 }
305
Vijay Pai82dd80a2015-03-24 10:36:08 -0700306 for (auto service = services_.begin(); service != services_.end();
307 service++) {
Craig Tillerd9b6fcf2015-07-07 16:28:20 -0700308 if (!server->RegisterService((*service)->host.get(), (*service)->service)) {
Craig Tiller0db1bef2015-02-09 13:47:39 -0800309 return nullptr;
310 }
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800311 }
Sree Kuchibhotla3ea9e242016-08-22 14:15:43 -0700312
Yuchen Zenga42ec212016-04-29 13:03:06 -0700313 for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
Vijay Pai15855f32016-06-10 12:25:32 -0700314 (*plugin)->InitServer(initializer);
Yuchen Zenga42ec212016-04-29 13:03:06 -0700315 }
Sree Kuchibhotla3ea9e242016-08-22 14:15:43 -0700316
Yang Gao005eb882015-03-11 22:17:13 -0700317 if (generic_service_) {
Yang Gao49996492015-03-12 16:40:19 -0700318 server->RegisterAsyncGenericService(generic_service_);
yang-g1ac6f452016-01-15 11:46:40 -0800319 } else {
320 for (auto it = services_.begin(); it != services_.end(); ++it) {
321 if ((*it)->service->has_generic_methods()) {
322 gpr_log(GPR_ERROR,
323 "Some methods were marked generic but there is no "
324 "generic service registered.");
325 return nullptr;
326 }
327 }
Yang Gao1c402332015-03-05 16:39:25 -0800328 }
Sree Kuchibhotla3ea9e242016-08-22 14:15:43 -0700329
Craig Tiller12352b22017-01-10 15:16:14 -0800330 bool added_port = false;
Vijay Pai82dd80a2015-03-24 10:36:08 -0700331 for (auto port = ports_.begin(); port != ports_.end(); port++) {
332 int r = server->AddListeningPort(port->addr, port->creds.get());
Craig Tiller12352b22017-01-10 15:16:14 -0800333 if (!r) {
334 if (added_port) server->Shutdown();
335 return nullptr;
336 }
337 added_port = true;
Vijay Pai82dd80a2015-03-24 10:36:08 -0700338 if (port->selected_port != nullptr) {
339 *port->selected_port = r;
Craig Tiller0db1bef2015-02-09 13:47:39 -0800340 }
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800341 }
Sree Kuchibhotla3ea9e242016-08-22 14:15:43 -0700342
yang-g61e461e2015-09-03 13:08:59 -0700343 auto cqs_data = cqs_.empty() ? nullptr : &cqs_[0];
Craig Tiller9d9313c2017-04-11 15:05:46 -0700344 server->Start(cqs_data, cqs_.size());
Sree Kuchibhotla3ea9e242016-08-22 14:15:43 -0700345
Yuchen Zenga42ec212016-04-29 13:03:06 -0700346 for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
Vijay Pai15855f32016-06-10 12:25:32 -0700347 (*plugin)->Finish(initializer);
Yuchen Zenga42ec212016-04-29 13:03:06 -0700348 }
Sree Kuchibhotla3ea9e242016-08-22 14:15:43 -0700349
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800350 return server;
351}
352
Yuchen Zeng3b8f3352016-05-03 12:18:13 -0700353void ServerBuilder::InternalAddPluginFactory(
354 std::unique_ptr<ServerBuilderPlugin> (*CreatePlugin)()) {
355 gpr_once_init(&once_init_plugin_list, do_plugin_list_init);
Yuchen Zeng7d099a52016-05-06 13:21:36 -0700356 (*g_plugin_factory_list).push_back(CreatePlugin);
Yuchen Zeng3b8f3352016-05-03 12:18:13 -0700357}
358
Muxi Yanf6b622c2017-05-17 10:34:10 -0700359ServerBuilder& ServerBuilder::EnableWorkaround(grpc_workaround_list id) {
Muxi Yancdc0d032017-05-09 16:04:10 -0700360 switch (id) {
361 case GRPC_WORKAROUND_ID_CRONET_COMPRESSION:
Muxi Yanf5b3db92017-05-09 17:12:24 -0700362 return AddChannelArgument(GRPC_ARG_WORKAROUND_CRONET_COMPRESSION, 1);
Muxi Yancdc0d032017-05-09 16:04:10 -0700363 default:
Muxi Yan928681d2017-05-16 10:16:23 -0700364 gpr_log(GPR_ERROR, "Workaround %u does not exist or is obsolete.", id);
Muxi Yanf5b3db92017-05-09 17:12:24 -0700365 return *this;
Muxi Yancdc0d032017-05-09 16:04:10 -0700366 }
367}
368
Craig Tiller190d3602015-02-18 09:23:38 -0800369} // namespace grpc