19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_H
27 #include "absl/status/status.h"
28 #include "absl/strings/string_view.h"
115 virtual void*
Alloc(
size_t size) = 0;
137 :
public std::iterator<
138 std::input_iterator_tag,
139 std::pair<absl::string_view, absl::string_view>,
141 std::pair<absl::string_view, absl::string_view>*,
142 std::pair<absl::string_view, absl::string_view>&
146 : md_(md), handle_(handle) {}
148 handle_ = md_->IteratorHandleNext(handle_);
152 return md_ == other.md_ && handle_ == other.handle_;
155 value_type
operator*()
const {
return md_->IteratorHandleGet(handle_); }
170 virtual void Add(absl::string_view key, absl::string_view value) = 0;
186 virtual intptr_t IteratorHandleNext(intptr_t handle)
const = 0;
187 virtual std::pair<absl::string_view , absl::string_view >
188 IteratorHandleGet(intptr_t handle)
const = 0;
286 const absl::Status& status,
287 std::unique_ptr<SubchannelPicker>) = 0;
295 absl::string_view message) = 0;
306 virtual const char*
name()
const = 0;
350 virtual const char*
name()
const = 0;
376 : parent_(std::move(parent)) {}
384 bool exit_idle_called_ =
false;
401 return work_serializer_;
407 return channel_control_helper_.get();
415 std::shared_ptr<WorkSerializer> work_serializer_;
419 std::unique_ptr<ChannelControlHelper> channel_control_helper_;
void grpc_channel_args_destroy(grpc_channel_args *a)
Destroy arguments created by grpc_channel_args_copy.
Definition: channel_args.cc:203
Definition: orphanable.h:76
Interface for accessing per-call state.
Definition: lb_policy.h:106
virtual absl::string_view ExperimentalGetCallAttribute(const char *key)=0
EXPERIMENTAL API.
virtual void * Alloc(size_t size)=0
Allocates memory associated with the call, which will be automatically freed when the call is complet...
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 ~CallState()=default
A proxy object implemented by the client channel and used by the LB policy to communicate with the ch...
Definition: lb_policy.h:274
ChannelControlHelper()=default
virtual RefCountedPtr< SubchannelInterface > CreateSubchannel(ServerAddress address, const grpc_channel_args &args)=0
Creates a new subchannel with the specified channel args.
virtual void RequestReresolution()=0
Requests that the resolver re-resolve.
virtual ~ChannelControlHelper()=default
virtual void UpdateState(grpc_connectivity_state state, const absl::Status &status, std::unique_ptr< SubchannelPicker >)=0
Sets the connectivity state and returns a new picker to be used by the client channel.
TraceSeverity
Adds a trace message associated with the channel.
Definition: lb_policy.h:293
@ TRACE_WARNING
Definition: lb_policy.h:293
@ TRACE_ERROR
Definition: lb_policy.h:293
@ TRACE_INFO
Definition: lb_policy.h:293
virtual void AddTraceEvent(TraceSeverity severity, absl::string_view message)=0
Interface for configuration data used by an LB policy implementation.
Definition: lb_policy.h:301
virtual const char * name() const =0
~Config() override=default
Definition: lb_policy.h:373
QueuePicker(RefCountedPtr< LoadBalancingPolicy > parent)
Definition: lb_policy.h:375
PickResult Pick(PickArgs args) override
Definition: lb_policy.cc:98
~QueuePicker() override
Definition: lb_policy.h:378
A subchannel picker is the object used to pick the subchannel to use for a given call.
Definition: lb_policy.h:264
virtual PickResult Pick(PickArgs args)=0
SubchannelPicker()=default
virtual ~SubchannelPicker()=default
Definition: lb_policy.h:388
~TransientFailurePicker() override
Definition: lb_policy.h:391
TransientFailurePicker(grpc_error_handle error)
Definition: lb_policy.h:390
PickResult Pick(PickArgs args) override
Definition: lb_policy.cc:138
Interface for load balancing policies.
Definition: lb_policy.h:82
virtual const char * name() const =0
Returns the name of the LB policy.
ChannelControlHelper * channel_control_helper() const
Definition: lb_policy.h:406
virtual void UpdateLocked(UpdateArgs)=0
Updates the policy with new data from the resolver.
virtual void ResetBackoffLocked()=0
Resets connection backoff.
grpc_pollset_set * interested_parties() const
Definition: lb_policy.h:365
void Orphan() override
Definition: lb_policy.cc:48
LoadBalancingPolicy & operator=(const LoadBalancingPolicy &)=delete
LoadBalancingPolicy(const LoadBalancingPolicy &)=delete
virtual void ExitIdleLocked()
Tries to enter a READY connectivity state.
Definition: lb_policy.h:360
virtual void ShutdownLocked()=0
Shuts down the policy.
~LoadBalancingPolicy() override
Definition: lb_policy.cc:44
LoadBalancingPolicy(Args args, intptr_t initial_refcount=1)
Definition: lb_policy.cc:34
std::shared_ptr< WorkSerializer > work_serializer() const
Definition: lb_policy.h:400
Definition: ref_counted.h:282
Definition: ref_counted_ptr.h:35
Definition: server_address.h:43
#define DEBUG_LOCATION
Definition: debug_location.h:41
#define GRPC_ERROR_NONE
The following "special" errors can be propagated without allocating memory.
Definition: error.h:228
#define GRPC_ERROR_UNREF(err)
Definition: error.h:254
grpc_connectivity_state
Connectivity state of a channel.
Definition: connectivity_state.h:27
grpc_error_handle error
Definition: lame_client.cc:54
Round Robin Policy.
Definition: backend_metric.cc:26
absl::InlinedVector< ServerAddress, 1 > ServerAddressList
Definition: server_address.h:111
DebugOnlyTraceFlag grpc_trace_lb_policy_refcount(false, "lb_policy_refcount")
Definition: lb_policy.h:41
struct grpc_pollset_set grpc_pollset_set
Definition: pollset_set.h:31
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Args used to instantiate an LB policy.
Definition: lb_policy.h:327
std::unique_ptr< ChannelControlHelper > channel_control_helper
Channel control helper.
Definition: lb_policy.h:333
std::shared_ptr< WorkSerializer > work_serializer
The work_serializer under which all LB policy calls will be run.
Definition: lb_policy.h:329
const grpc_channel_args * args
Channel args.
Definition: lb_policy.h:339
Definition: lb_policy.h:85
std::map< absl::string_view, double > request_cost
Application-specific requests cost metrics.
Definition: lb_policy.h:97
uint64_t requests_per_second
Total requests per second being served by the backend.
Definition: lb_policy.h:93
double mem_utilization
Memory utilization expressed as a fraction of available memory resources.
Definition: lb_policy.h:90
double cpu_utilization
CPU utilization expressed as a fraction of available CPU resources.
Definition: lb_policy.h:87
std::map< absl::string_view, double > utilization
Application-specific resource utilization metrics.
Definition: lb_policy.h:101
Arguments used when picking a subchannel for a call.
Definition: lb_policy.h:192
absl::string_view path
The path of the call. Indicates the RPC service and method name.
Definition: lb_policy.h:194
MetadataInterface * initial_metadata
Initial metadata associated with the picking call.
Definition: lb_policy.h:199
CallState * call_state
An interface for accessing call state.
Definition: lb_policy.h:202
The result of picking a subchannel for a call.
Definition: lb_policy.h:206
grpc_error_handle error
Used only if type is PICK_FAILED.
Definition: lb_policy.h:233
ResultType type
Definition: lb_policy.h:223
std::function< void(grpc_error_handle, MetadataInterface *, CallState *)> recv_trailing_metadata_ready
Used only if type is PICK_COMPLETE.
Definition: lb_policy.h:247
RefCountedPtr< SubchannelInterface > subchannel
Used only if type is PICK_COMPLETE.
Definition: lb_policy.h:227
ResultType
Definition: lb_policy.h:207
@ PICK_COMPLETE
Pick complete.
Definition: lb_policy.h:211
@ PICK_FAILED
Pick failed.
Definition: lb_policy.h:221
@ PICK_QUEUE
Pick cannot be completed until something changes on the control plane.
Definition: lb_policy.h:215
Data passed to the UpdateLocked() method when new addresses and config are available.
Definition: lb_policy.h:311
ServerAddressList addresses
Definition: lb_policy.h:312
const grpc_channel_args * args
Definition: lb_policy.h:314
RefCountedPtr< Config > config
Definition: lb_policy.h:313
~UpdateArgs()
Definition: lb_policy.h:319
UpdateArgs & operator=(const UpdateArgs &other)
Definition: lb_policy.cc:71
Definition: error_internal.h:41