// // Copyright 2015 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #ifndef GRPC_SRC_CORE_LIB_LOAD_BALANCING_LB_POLICY_H #define GRPC_SRC_CORE_LIB_LOAD_BALANCING_LB_POLICY_H #include <grpc/support/port_platform.h> #include <stddef.h> #include <stdint.h> #include <memory> #include <string> #include <utility> #include <vector> #include "absl/base/thread_annotations.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "absl/types/variant.h" #include <grpc/event_engine/event_engine.h> #include <grpc/impl/connectivity_state.h> #include "src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/dual_ref_counted.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/gprpp/work_serializer.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/load_balancing/subchannel_interface.h" #include "src/core/lib/resolver/server_address.h" namespace grpc_core { extern DebugOnlyTraceFlag grpc_trace_lb_policy_refcount; /// Interface for load balancing policies. /// /// The following concepts are used here: /// /// Channel: An abstraction that manages connections to backend servers /// on behalf of a client application. The application creates a channel /// for a given server name and then sends calls (RPCs) on it, and the /// channel figures out which backend server to send each call to. A channel /// contains a resolver, a load balancing policy (or a tree of LB policies), /// and a set of one or more subchannels. /// /// Subchannel: A subchannel represents a connection to one backend server. /// The LB policy decides which subchannels to create, manages the /// connectivity state of those subchannels, and decides which subchannel /// to send any given call to. /// /// Resolver: A plugin that takes a gRPC server URI and resolves it to a /// list of one or more addresses and a service config, as described /// in https://github.com/grpc/grpc/blob/master/doc/naming.md. See /// resolver.h for the resolver API. /// /// Load Balancing (LB) Policy: A plugin that takes a list of addresses /// from the resolver, maintains and manages a subchannel for each /// backend address, and decides which subchannel to send each call on. /// An LB policy has two parts: /// - A LoadBalancingPolicy, which deals with the control plane work of /// managing subchannels. /// - A SubchannelPicker, which handles the data plane work of /// determining which subchannel a given call should be sent on. /// LoadBalacingPolicy API. /// /// Note: All methods with a "Locked" suffix must be called from the /// work_serializer passed to the constructor. /// /// Any I/O done by the LB policy should be done under the pollset_set /// returned by \a interested_parties(). // TODO(roth): Once we move to EventManager-based polling, remove the // interested_parties() hooks from the API. class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> { … }; } // namespace grpc_core #endif // GRPC_SRC_CORE_LIB_LOAD_BALANCING_LB_POLICY_H