GRPC Core  9.0.0
Data Structures | Public Member Functions | Protected Member Functions
grpc_core::LoadBalancingPolicy Class Referenceabstract

Interface for load balancing policies. More...

#include <lb_policy.h>

Data Structures

struct  Args
 Args used to instantiate an LB policy. More...
 
struct  BackendMetricData
 
class  CallState
 Interface for accessing per-call state. More...
 
class  ChannelControlHelper
 A proxy object implemented by the client channel and used by the LB policy to communicate with the channel. More...
 
class  Config
 Interface for configuration data used by an LB policy implementation. More...
 
class  MetadataInterface
 Interface for accessing metadata. More...
 
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  SubchannelPicker
 A subchannel picker is the object used to pick the subchannel to use for a given call. More...
 
class  TransientFailurePicker
 
struct  UpdateArgs
 Data passed to the UpdateLocked() method when new addresses and config are available. More...
 

Public Member Functions

 LoadBalancingPolicy (Args args, intptr_t initial_refcount=1)
 
virtual ~LoadBalancingPolicy ()
 
 LoadBalancingPolicy (const LoadBalancingPolicy &)=delete
 
LoadBalancingPolicyoperator= (const LoadBalancingPolicy &)=delete
 
virtual const char * name () const =0
 Returns the name of the LB policy. More...
 
virtual void UpdateLocked (UpdateArgs)=0
 Updates the policy with new data from the resolver. More...
 
virtual void ExitIdleLocked ()
 Tries to enter a READY connectivity state. More...
 
virtual void ResetBackoffLocked ()=0
 Resets connection backoff. More...
 
grpc_pollset_setinterested_parties () const
 
void Orphan () 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
 Orphanable (const Orphanable &)=delete
 
Orphanableoperator= (const Orphanable &)=delete
 

Protected Member Functions

Combinercombiner () const
 
ChannelControlHelperchannel_control_helper () const
 
virtual void ShutdownLocked ()=0
 Shuts down the policy. More...
 
- Protected Member Functions inherited from grpc_core::InternallyRefCounted< LoadBalancingPolicy >
 InternallyRefCounted (TraceFlagT *trace_flag=nullptr, intptr_t initial_refcount=1)
 
virtual ~InternallyRefCounted ()=default
 
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)
 
- Protected Member Functions inherited from grpc_core::Orphanable
 Orphanable ()
 
virtual ~Orphanable ()
 

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 combiner passed to the constructor.

Any I/O done by the LB policy should be done under the pollset_set returned by interested_parties().

Constructor & Destructor Documentation

◆ LoadBalancingPolicy() [1/2]

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

◆ ~LoadBalancingPolicy()

grpc_core::LoadBalancingPolicy::~LoadBalancingPolicy ( )
virtual

◆ 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

◆ combiner()

Combiner* grpc_core::LoadBalancingPolicy::combiner ( ) const
inlineprotected

◆ 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::ResolvingLoadBalancingPolicy.

◆ interested_parties()

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

◆ name()

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

Returns the name of the LB policy.

Implemented in grpc_core::ResolvingLoadBalancingPolicy.

◆ operator=()

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

◆ Orphan()

void grpc_core::LoadBalancingPolicy::Orphan ( )
overridevirtual

Implements grpc_core::Orphanable.

◆ ResetBackoffLocked()

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

Resets connection backoff.

Implemented in grpc_core::ResolvingLoadBalancingPolicy.

◆ ShutdownLocked()

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

Shuts down the policy.

◆ 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::ResolvingLoadBalancingPolicy.


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