Go to the documentation of this file.
19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_H
114 virtual void*
Alloc(
size_t size) = 0;
126 :
public std::iterator<std::input_iterator_tag,
127 std::pair<StringView, StringView>,
129 std::pair<StringView, StringView>*,
130 std::pair<StringView, StringView>&
134 : md_(md), handle_(handle) {}
136 handle_ = md_->IteratorHandleNext(handle_);
140 return md_ == other.md_ && handle_ == other.handle_;
143 value_type
operator*()
const {
return md_->IteratorHandleGet(handle_); }
174 virtual intptr_t IteratorHandleNext(intptr_t handle)
const = 0;
176 IteratorHandleGet(intptr_t handle)
const = 0;
272 std::unique_ptr<SubchannelPicker>) = 0;
290 virtual const char*
name()
const = 0;
338 virtual const char*
name()
const = 0;
364 : parent_(std::move(parent)) {}
371 static void CallExitIdle(
void* arg,
grpc_error* error);
374 bool exit_idle_called_ =
false;
395 return channel_control_helper_.get();
407 std::unique_ptr<ChannelControlHelper> channel_control_helper_;
virtual ~CallState()=default
UpdateArgs & operator=(const UpdateArgs &other)
Definition: lb_policy.cc:68
Definition: string_view.h:69
void Orphan() override
Definition: lb_policy.cc:45
virtual ~LoadBalancingPolicy()
Definition: lb_policy.cc:40
const grpc_channel_args * args
Channel args.
Definition: lb_policy.h:327
@ PICK_FAILED
Pick failed.
Definition: lb_policy.h:207
#define GRPC_ERROR_NONE
The following "special" errors can be propagated without allocating memory.
Definition: error.h:125
virtual const char * name() const =0
Returns the name of the LB policy.
~UpdateArgs()
Definition: lb_policy.h:303
virtual RefCountedPtr< SubchannelInterface > CreateSubchannel(const grpc_channel_args &args)=0
Creates a new subchannel with the specified channel args.
Combiner * combiner() const
Definition: lb_policy.h:390
RefCountedPtr< Config > config
Definition: lb_policy.h:297
CallState * call_state
An interface for accessing call state.
Definition: lb_policy.h:188
Definition: combiner.h:33
virtual void UpdateLocked(UpdateArgs)=0
Updates the policy with new data from the resolver.
grpc_error * error
Used only if type is PICK_FAILED.
Definition: lb_policy.h:219
Round Robin Policy.
Definition: backend_metric.cc:24
LoadBalancingPolicy & operator=(const LoadBalancingPolicy &)=delete
virtual ~SubchannelPicker()=default
double mem_utilization
Memory utilization expressed as a fraction of available memory resources.
Definition: lb_policy.h:89
ChannelControlHelper * channel_control_helper() const
Definition: lb_policy.h:394
Definition: ref_counted.h:248
Definition: lb_policy.h:361
ResultType
Definition: lb_policy.h:193
virtual void * Alloc(size_t size)=0
Allocates memory associated with the call, which will be automatically freed when the call is complet...
const grpc_channel_args * args
Definition: lb_policy.h:298
~TransientFailurePicker() override
Definition: lb_policy.h:381
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Combiner * combiner
The combiner under which all LB policy calls will be run.
Definition: lb_policy.h:317
grpc_connectivity_state
Connectivity state of a channel.
Definition: connectivity_state.h:27
ResultType type
Definition: lb_policy.h:209
Definition: ref_counted_ptr.h:35
double cpu_utilization
CPU utilization expressed as a fraction of available CPU resources.
Definition: lb_policy.h:86
virtual void ShutdownLocked()=0
Shuts down the policy.
#define DEBUG_LOCATION
Definition: debug_location.h:41
@ PICK_COMPLETE
Pick complete.
Definition: lb_policy.h:197
virtual const char * name() const =0
DebugOnlyTraceFlag grpc_trace_lb_policy_refcount(false, "lb_policy_refcount")
Definition: lb_policy.h:40
grpc_pollset_set * interested_parties() const
Definition: lb_policy.h:353
PickResult Pick(PickArgs args) override
Definition: lb_policy.cc:129
std::map< StringView, double, StringLess > request_cost
Application-specific requests cost metrics.
Definition: lb_policy.h:96
std::function< void(grpc_error *, MetadataInterface *, CallState *)> recv_trailing_metadata_ready
Used only if type is PICK_COMPLETE.
Definition: lb_policy.h:230
QueuePicker(RefCountedPtr< LoadBalancingPolicy > parent)
Definition: lb_policy.h:363
@ TRACE_ERROR
Definition: lb_policy.h:278
Interface for load balancing policies.
Definition: lb_policy.h:81
virtual PickResult Pick(PickArgs args)=0
TransientFailurePicker(grpc_error *error)
Definition: lb_policy.h:380
void grpc_channel_args_destroy(grpc_channel_args *a)
Destroy arguments created by grpc_channel_args_copy.
Definition: channel_args.cc:197
Interface for accessing per-call state.
Definition: lb_policy.h:105
Interface for configuration data used by an LB policy implementation.
Definition: lb_policy.h:285
PickResult Pick(PickArgs args) override
Definition: lb_policy.cc:92
TraceSeverity
Adds a trace message associated with the channel.
Definition: lb_policy.h:278
A subchannel picker is the object used to pick the subchannel to use for a given call.
Definition: lb_policy.h:247
SubchannelPicker()=default
ServerAddressList addresses
Definition: lb_policy.h:296
Definition: orphanable.h:77
Data passed to the UpdateLocked() method when new addresses and config are available.
Definition: lb_policy.h:295
virtual const BackendMetricData * GetBackendMetricData()=0
Returns the backend metric data returned by the server for the call, or null if no backend metric dat...
virtual void ExitIdleLocked()
Tries to enter a READY connectivity state.
Definition: lb_policy.h:348
Definition: lb_policy.h:84
#define GRPC_ERROR_UNREF(err)
Definition: error.h:186
@ TRACE_WARNING
Definition: lb_policy.h:278
std::map< StringView, double, StringLess > utilization
Application-specific resource utilization metrics.
Definition: lb_policy.h:100
LoadBalancingPolicy(const LoadBalancingPolicy &)=delete
uint64_t requests_per_second
Total requests per second being served by the backend.
Definition: lb_policy.h:92
virtual void AddTraceEvent(TraceSeverity severity, StringView message)=0
virtual void ResetBackoffLocked()=0
Resets connection backoff.
ChannelControlHelper()=default
@ PICK_QUEUE
Pick cannot be completed until something changes on the control plane.
Definition: lb_policy.h:201
MetadataInterface * initial_metadata
Initial metadata associated with the picking call.
Definition: lb_policy.h:185
Definition: error_internal.h:39
virtual void UpdateState(grpc_connectivity_state state, std::unique_ptr< SubchannelPicker >)=0
Sets the connectivity state and returns a new picker to be used by the client channel.
~QueuePicker()
Definition: lb_policy.h:366
LoadBalancingPolicy(Args args, intptr_t initial_refcount=1)
Definition: lb_policy.cc:34
Args used to instantiate an LB policy.
Definition: lb_policy.h:311
The result of picking a subchannel for a call.
Definition: lb_policy.h:192
std::unique_ptr< ChannelControlHelper > channel_control_helper
Channel control helper.
Definition: lb_policy.h:321
Definition: lb_policy.h:378
Arguments used when picking a subchannel for a call.
Definition: lb_policy.h:180
virtual ~Config()=default
A proxy object implemented by the client channel and used by the LB policy to communicate with the ch...
Definition: lb_policy.h:260
virtual void RequestReresolution()=0
Requests that the resolver re-resolve.
RefCountedPtr< SubchannelInterface > subchannel
Used only if type is PICK_COMPLETE.
Definition: lb_policy.h:213
virtual ~ChannelControlHelper()=default
@ TRACE_INFO
Definition: lb_policy.h:278
struct grpc_pollset_set grpc_pollset_set
Definition: pollset_set.h:31