1 /*
2 *
3 * Copyright 2015 gRPC authors.
4 *
5 * 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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * 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.
16 *
17 */
18
19 #include <grpc/support/port_platform.h>
20
21 #include <limits.h>
22 #include <stdbool.h>
23 #include <string.h>
24
25 #include <grpc/support/alloc.h>
26
27 #include "src/core/ext/filters/client_channel/backup_poller.h"
28 #include "src/core/ext/filters/client_channel/client_channel.h"
29 #include "src/core/ext/filters/client_channel/client_channel_channelz.h"
30 #include "src/core/ext/filters/client_channel/global_subchannel_pool.h"
31 #include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
32 #include "src/core/ext/filters/client_channel/http_proxy.h"
33 #include "src/core/ext/filters/client_channel/lb_policy_registry.h"
34 #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
35 #include "src/core/ext/filters/client_channel/resolver_registry.h"
36 #include "src/core/ext/filters/client_channel/resolver_result_parsing.h"
37 #include "src/core/ext/filters/client_channel/retry_throttle.h"
38 #include "src/core/ext/filters/client_channel/service_config_parser.h"
39 #include "src/core/lib/surface/channel_init.h"
40
append_filter(grpc_channel_stack_builder * builder,void * arg)41 static bool append_filter(grpc_channel_stack_builder* builder, void* arg) {
42 return grpc_channel_stack_builder_append_filter(
43 builder, static_cast<const grpc_channel_filter*>(arg), nullptr, nullptr);
44 }
45
grpc_client_channel_init(void)46 void grpc_client_channel_init(void) {
47 grpc_core::ServiceConfigParser::Init();
48 grpc_core::internal::ClientChannelServiceConfigParser::Register();
49 grpc_core::LoadBalancingPolicyRegistry::Builder::InitRegistry();
50 grpc_core::ResolverRegistry::Builder::InitRegistry();
51 grpc_core::internal::ServerRetryThrottleMap::Init();
52 grpc_core::ProxyMapperRegistry::Init();
53 grpc_core::RegisterHttpProxyMapper();
54 grpc_core::GlobalSubchannelPool::Init();
55 grpc_channel_init_register_stage(
56 GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter,
57 const_cast<grpc_channel_filter*>(&grpc_client_channel_filter));
58 grpc_http_connect_register_handshaker_factory();
59 grpc_client_channel_global_init_backup_polling();
60 }
61
grpc_client_channel_shutdown(void)62 void grpc_client_channel_shutdown(void) {
63 grpc_core::GlobalSubchannelPool::Shutdown();
64 grpc_channel_init_shutdown();
65 grpc_core::ProxyMapperRegistry::Shutdown();
66 grpc_core::internal::ServerRetryThrottleMap::Shutdown();
67 grpc_core::ResolverRegistry::Builder::ShutdownRegistry();
68 grpc_core::LoadBalancingPolicyRegistry::Builder::ShutdownRegistry();
69 grpc_core::ServiceConfigParser::Shutdown();
70 }
71