Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / deps / grpc / src / core / ext / filters / client_channel / lb_policy_registry.h
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 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H
21
22 #include <grpc/support/port_platform.h>
23
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"
27
28 namespace grpc_core {
29
30 class LoadBalancingPolicyRegistry {
31  public:
32   /// Methods used to create and populate the LoadBalancingPolicyRegistry.
33   /// NOT THREAD SAFE -- to be used only during global gRPC
34   /// initialization and shutdown.
35   class Builder {
36    public:
37     /// Global initialization and shutdown hooks.
38     static void InitRegistry();
39     static void ShutdownRegistry();
40
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);
45   };
46
47   /// Creates an LB policy of the type specified by \a name.
48   static OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
49       const char* name, LoadBalancingPolicy::Args args);
50
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);
56
57   /// Returns a parsed object of the load balancing policy to be used from a
58   /// LoadBalancingConfig array \a json.
59   static RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
60       const grpc_json* json, grpc_error** error);
61 };
62
63 }  // namespace grpc_core
64
65 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H */