Classes | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
grpc_core::LoadBalancingPolicy Class Referenceabstract

#include <lb_policy.h>

Inheritance diagram for grpc_core::LoadBalancingPolicy:
Inheritance graph
[legend]

Classes

struct  Args
 Args used to instantiate an LB policy. More...
 
class  BackendMetricAccessor
 
class  CallState
 
class  ChannelControlHelper
 
class  Config
 
class  MetadataInterface
 
struct  PickArgs
 Arguments used when picking a subchannel for a call. More...
 
struct  PickResult
 The result of picking a subchannel for a call. More...
 
class  QueuePicker
 
class  SubchannelCallTrackerInterface
 
class  SubchannelPicker
 
class  TransientFailurePicker
 
struct  UpdateArgs
 

Public Member Functions

virtual void ExitIdleLocked ()
 
grpc_pollset_setinterested_parties () const
 
 LoadBalancingPolicy (Args args, intptr_t initial_refcount=1)
 
 LoadBalancingPolicy (const LoadBalancingPolicy &)=delete
 
virtual const char * name () const =0
 Returns the name of the LB policy. More...
 
LoadBalancingPolicyoperator= (const LoadBalancingPolicy &)=delete
 
void Orphan () override
 
virtual void ResetBackoffLocked ()=0
 Resets connection backoff. More...
 
virtual void UpdateLocked (UpdateArgs)=0
 
 ~LoadBalancingPolicy () override
 
- Public Member Functions inherited from grpc_core::InternallyRefCounted< LoadBalancingPolicy >
 InternallyRefCounted (const InternallyRefCounted &)=delete
 
InternallyRefCountedoperator= (const InternallyRefCounted &)=delete
 
- Public Member Functions inherited from grpc_core::Orphanable
Orphanableoperator= (const Orphanable &)=delete
 
 Orphanable (const Orphanable &)=delete
 

Protected Member Functions

ChannelControlHelperchannel_control_helper () const
 
virtual void ShutdownLocked ()=0
 Shuts down the policy. More...
 
std::shared_ptr< WorkSerializerwork_serializer () const
 
- Protected Member Functions inherited from grpc_core::InternallyRefCounted< LoadBalancingPolicy >
 InternallyRefCounted (const char *trace=nullptr, intptr_t initial_refcount=1)
 
RefCountedPtr< LoadBalancingPolicyRef () GRPC_MUST_USE_RESULT
 
RefCountedPtr< LoadBalancingPolicyRef (const DebugLocation &location, const char *reason) GRPC_MUST_USE_RESULT
 
void Unref ()
 
void Unref (const DebugLocation &location, const char *reason)
 
 ~InternallyRefCounted () override=default
 
- Protected Member Functions inherited from grpc_core::Orphanable
 Orphanable ()
 
virtual ~Orphanable ()
 

Private Attributes

std::unique_ptr< ChannelControlHelperchannel_control_helper_
 Channel control helper. More...
 
grpc_pollset_setinterested_parties_
 Owned pointer to interested parties in load balancing decisions. More...
 
std::shared_ptr< WorkSerializerwork_serializer_
 Work Serializer under which LB policy actions take place. More...
 

Detailed Description

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:

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 interested_parties().

Definition at line 95 of file lb_policy.h.

Constructor & Destructor Documentation

◆ LoadBalancingPolicy() [1/2]

grpc_core::LoadBalancingPolicy::LoadBalancingPolicy ( Args  args,
intptr_t  initial_refcount = 1 
)
explicit

Definition at line 36 of file lb_policy.cc.

◆ ~LoadBalancingPolicy()

grpc_core::LoadBalancingPolicy::~LoadBalancingPolicy ( )
override

Definition at line 46 of file lb_policy.cc.

◆ LoadBalancingPolicy() [2/2]

grpc_core::LoadBalancingPolicy::LoadBalancingPolicy ( const LoadBalancingPolicy )
delete

Member Function Documentation

◆ channel_control_helper()

ChannelControlHelper* grpc_core::LoadBalancingPolicy::channel_control_helper ( ) const
inlineprotected

Definition at line 426 of file lb_policy.h.

◆ ExitIdleLocked()

virtual void grpc_core::LoadBalancingPolicy::ExitIdleLocked ( )
inlinevirtual

Tries to enter a READY connectivity state. This is a no-op by default, since most LB policies never go into IDLE state.

Reimplemented in grpc_core::ChildPolicyHandler.

Definition at line 379 of file lb_policy.h.

◆ interested_parties()

grpc_pollset_set* grpc_core::LoadBalancingPolicy::interested_parties ( ) const
inline

Definition at line 384 of file lb_policy.h.

◆ name()

virtual const char* grpc_core::LoadBalancingPolicy::name ( ) const
pure virtual

Returns the name of the LB policy.

Implemented in grpc_core::ChildPolicyHandler.

◆ operator=()

LoadBalancingPolicy& grpc_core::LoadBalancingPolicy::operator= ( const LoadBalancingPolicy )
delete

◆ Orphan()

void grpc_core::LoadBalancingPolicy::Orphan ( )
overridevirtual

Implements grpc_core::Orphanable.

Definition at line 50 of file lb_policy.cc.

◆ ResetBackoffLocked()

virtual void grpc_core::LoadBalancingPolicy::ResetBackoffLocked ( )
pure virtual

Resets connection backoff.

Implemented in grpc_core::ChildPolicyHandler.

◆ ShutdownLocked()

virtual void grpc_core::LoadBalancingPolicy::ShutdownLocked ( )
protectedpure virtual

Shuts down the policy.

Implemented in grpc_core::ChildPolicyHandler.

◆ UpdateLocked()

virtual void grpc_core::LoadBalancingPolicy::UpdateLocked ( UpdateArgs  )
pure virtual

Updates the policy with new data from the resolver. Will be invoked immediately after LB policy is constructed, and then again whenever the resolver returns a new result.

Implemented in grpc_core::ChildPolicyHandler.

◆ work_serializer()

std::shared_ptr<WorkSerializer> grpc_core::LoadBalancingPolicy::work_serializer ( ) const
inlineprotected

Definition at line 420 of file lb_policy.h.

Member Data Documentation

◆ channel_control_helper_

std::unique_ptr<ChannelControlHelper> grpc_core::LoadBalancingPolicy::channel_control_helper_
private

Channel control helper.

Definition at line 439 of file lb_policy.h.

◆ interested_parties_

grpc_pollset_set* grpc_core::LoadBalancingPolicy::interested_parties_
private

Owned pointer to interested parties in load balancing decisions.

Definition at line 437 of file lb_policy.h.

◆ work_serializer_

std::shared_ptr<WorkSerializer> grpc_core::LoadBalancingPolicy::work_serializer_
private

Work Serializer under which LB policy actions take place.

Definition at line 435 of file lb_policy.h.


The documentation for this class was generated from the following files:


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:36