3 * Copyright 2015 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H
22 #include <grpc/support/port_platform.h>
24 #include "src/core/ext/filters/client_channel/lb_policy_factory.h"
25 #include "src/core/lib/gprpp/memory.h"
26 #include "src/core/lib/gprpp/orphanable.h"
30 class LoadBalancingPolicyRegistry {
32 /// Methods used to create and populate the LoadBalancingPolicyRegistry.
33 /// NOT THREAD SAFE -- to be used only during global gRPC
34 /// initialization and shutdown.
37 /// Global initialization and shutdown hooks.
38 static void InitRegistry();
39 static void ShutdownRegistry();
41 /// Registers an LB policy factory. The factory will be used to create an
42 /// LB policy whose name matches that of the factory.
43 static void RegisterLoadBalancingPolicyFactory(
44 UniquePtr<LoadBalancingPolicyFactory> factory);
47 /// Creates an LB policy of the type specified by \a name.
48 static OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
49 const char* name, LoadBalancingPolicy::Args args);
51 /// Returns true if the LB policy factory specified by \a name exists in this
52 /// registry. If the load balancing policy requires a config to be specified
53 /// then sets \a requires_config to true.
54 static bool LoadBalancingPolicyExists(const char* name,
55 bool* requires_config);
57 /// Returns a parsed object of the load balancing policy to be used from a
58 /// LoadBalancingConfig array \a json.
59 static RefCountedPtr<ParsedLoadBalancingConfig> ParseLoadBalancingConfig(
60 const grpc_json* json, grpc_error** error);
63 } // namespace grpc_core
65 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H */