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, const LoadBalancingPolicy::Args& args); 50 }; 51 52 } // namespace grpc_core 53 54 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H */ 55