|
|
@ -87,8 +87,8 @@ |
|
|
|
// Channel arg key for server URI string.
|
|
|
|
// Channel arg key for server URI string.
|
|
|
|
#define GRPC_ARG_SERVER_URI "grpc.server_uri" |
|
|
|
#define GRPC_ARG_SERVER_URI "grpc.server_uri" |
|
|
|
|
|
|
|
|
|
|
|
// Channel arg containing a pointer to the ClientChannel object.
|
|
|
|
// Channel arg containing a pointer to the ClientChannelFilter object.
|
|
|
|
#define GRPC_ARG_CLIENT_CHANNEL "grpc.internal.client_channel" |
|
|
|
#define GRPC_ARG_CLIENT_CHANNEL "grpc.internal.client_channel_filter" |
|
|
|
|
|
|
|
|
|
|
|
// Max number of batches that can be pending on a call at any given
|
|
|
|
// Max number of batches that can be pending on a call at any given
|
|
|
|
// time. This includes one batch for each of the following ops:
|
|
|
|
// time. This includes one batch for each of the following ops:
|
|
|
@ -102,7 +102,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
namespace grpc_core { |
|
|
|
namespace grpc_core { |
|
|
|
|
|
|
|
|
|
|
|
class ClientChannel { |
|
|
|
class ClientChannelFilter { |
|
|
|
public: |
|
|
|
public: |
|
|
|
static const grpc_channel_filter kFilterVtableWithPromises; |
|
|
|
static const grpc_channel_filter kFilterVtableWithPromises; |
|
|
|
static const grpc_channel_filter kFilterVtableWithoutPromises; |
|
|
|
static const grpc_channel_filter kFilterVtableWithoutPromises; |
|
|
@ -115,9 +115,9 @@ class ClientChannel { |
|
|
|
struct RawPointerChannelArgTag {}; |
|
|
|
struct RawPointerChannelArgTag {}; |
|
|
|
static absl::string_view ChannelArgName() { return GRPC_ARG_CLIENT_CHANNEL; } |
|
|
|
static absl::string_view ChannelArgName() { return GRPC_ARG_CLIENT_CHANNEL; } |
|
|
|
|
|
|
|
|
|
|
|
// Returns the ClientChannel object from channel, or null if channel
|
|
|
|
// Returns the ClientChannelFilter object from channel, or null if channel
|
|
|
|
// is not a client channel.
|
|
|
|
// is not a client channel.
|
|
|
|
static ClientChannel* GetFromChannel(Channel* channel); |
|
|
|
static ClientChannelFilter* GetFromChannel(Channel* channel); |
|
|
|
|
|
|
|
|
|
|
|
static ArenaPromise<ServerMetadataHandle> MakeCallPromise( |
|
|
|
static ArenaPromise<ServerMetadataHandle> MakeCallPromise( |
|
|
|
grpc_channel_element* elem, CallArgs call_args, |
|
|
|
grpc_channel_element* elem, CallArgs call_args, |
|
|
@ -196,7 +196,7 @@ class ClientChannel { |
|
|
|
// via grpc_client_channel_watch_connectivity_state().
|
|
|
|
// via grpc_client_channel_watch_connectivity_state().
|
|
|
|
class ExternalConnectivityWatcher : public ConnectivityStateWatcherInterface { |
|
|
|
class ExternalConnectivityWatcher : public ConnectivityStateWatcherInterface { |
|
|
|
public: |
|
|
|
public: |
|
|
|
ExternalConnectivityWatcher(ClientChannel* chand, |
|
|
|
ExternalConnectivityWatcher(ClientChannelFilter* chand, |
|
|
|
grpc_polling_entity pollent, |
|
|
|
grpc_polling_entity pollent, |
|
|
|
grpc_connectivity_state* state, |
|
|
|
grpc_connectivity_state* state, |
|
|
|
grpc_closure* on_complete, |
|
|
|
grpc_closure* on_complete, |
|
|
@ -205,7 +205,7 @@ class ClientChannel { |
|
|
|
~ExternalConnectivityWatcher() override; |
|
|
|
~ExternalConnectivityWatcher() override; |
|
|
|
|
|
|
|
|
|
|
|
// Removes the watcher from the external_watchers_ map.
|
|
|
|
// Removes the watcher from the external_watchers_ map.
|
|
|
|
static void RemoveWatcherFromExternalWatchersMap(ClientChannel* chand, |
|
|
|
static void RemoveWatcherFromExternalWatchersMap(ClientChannelFilter* chand, |
|
|
|
grpc_closure* on_complete, |
|
|
|
grpc_closure* on_complete, |
|
|
|
bool cancel); |
|
|
|
bool cancel); |
|
|
|
|
|
|
|
|
|
|
@ -222,7 +222,7 @@ class ClientChannel { |
|
|
|
void RemoveWatcherLocked() |
|
|
|
void RemoveWatcherLocked() |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(*chand_->work_serializer_); |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(*chand_->work_serializer_); |
|
|
|
|
|
|
|
|
|
|
|
ClientChannel* chand_; |
|
|
|
ClientChannelFilter* chand_; |
|
|
|
grpc_polling_entity pollent_; |
|
|
|
grpc_polling_entity pollent_; |
|
|
|
grpc_connectivity_state initial_state_; |
|
|
|
grpc_connectivity_state initial_state_; |
|
|
|
grpc_connectivity_state* state_; |
|
|
|
grpc_connectivity_state* state_; |
|
|
@ -231,8 +231,9 @@ class ClientChannel { |
|
|
|
std::atomic<bool> done_{false}; |
|
|
|
std::atomic<bool> done_{false}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
ClientChannel(grpc_channel_element_args* args, grpc_error_handle* error); |
|
|
|
ClientChannelFilter(grpc_channel_element_args* args, |
|
|
|
~ClientChannel(); |
|
|
|
grpc_error_handle* error); |
|
|
|
|
|
|
|
~ClientChannelFilter(); |
|
|
|
|
|
|
|
|
|
|
|
// Filter vtable functions.
|
|
|
|
// Filter vtable functions.
|
|
|
|
static grpc_error_handle Init(grpc_channel_element* elem, |
|
|
|
static grpc_error_handle Init(grpc_channel_element* elem, |
|
|
@ -378,15 +379,15 @@ class ClientChannel { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// ClientChannel::LoadBalancedCall
|
|
|
|
// ClientChannelFilter::LoadBalancedCall
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
// TODO(roth): As part of simplifying cancellation in the filter stack,
|
|
|
|
// TODO(roth): As part of simplifying cancellation in the filter stack,
|
|
|
|
// this should no longer need to be ref-counted.
|
|
|
|
// this should no longer need to be ref-counted.
|
|
|
|
class ClientChannel::LoadBalancedCall |
|
|
|
class ClientChannelFilter::LoadBalancedCall |
|
|
|
: public InternallyRefCounted<LoadBalancedCall, UnrefCallDtor> { |
|
|
|
: public InternallyRefCounted<LoadBalancedCall, UnrefCallDtor> { |
|
|
|
public: |
|
|
|
public: |
|
|
|
LoadBalancedCall(ClientChannel* chand, |
|
|
|
LoadBalancedCall(ClientChannelFilter* chand, |
|
|
|
grpc_call_context_element* call_context, |
|
|
|
grpc_call_context_element* call_context, |
|
|
|
absl::AnyInvocable<void()> on_commit, |
|
|
|
absl::AnyInvocable<void()> on_commit, |
|
|
|
bool is_transparent_retry); |
|
|
|
bool is_transparent_retry); |
|
|
@ -396,15 +397,15 @@ class ClientChannel::LoadBalancedCall |
|
|
|
|
|
|
|
|
|
|
|
// Called by channel when removing a call from the list of queued calls.
|
|
|
|
// Called by channel when removing a call from the list of queued calls.
|
|
|
|
void RemoveCallFromLbQueuedCallsLocked() |
|
|
|
void RemoveCallFromLbQueuedCallsLocked() |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::lb_mu_); |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_); |
|
|
|
|
|
|
|
|
|
|
|
// Called by the channel for each queued call when a new picker
|
|
|
|
// Called by the channel for each queued call when a new picker
|
|
|
|
// becomes available.
|
|
|
|
// becomes available.
|
|
|
|
virtual void RetryPickLocked() |
|
|
|
virtual void RetryPickLocked() |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::lb_mu_) = 0; |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_) = 0; |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
protected: |
|
|
|
ClientChannel* chand() const { return chand_; } |
|
|
|
ClientChannelFilter* chand() const { return chand_; } |
|
|
|
ClientCallTracer::CallAttemptTracer* call_attempt_tracer() const { |
|
|
|
ClientCallTracer::CallAttemptTracer* call_attempt_tracer() const { |
|
|
|
return static_cast<ClientCallTracer::CallAttemptTracer*>( |
|
|
|
return static_cast<ClientCallTracer::CallAttemptTracer*>( |
|
|
|
call_context_[GRPC_CONTEXT_CALL_TRACER].value); |
|
|
|
call_context_[GRPC_CONTEXT_CALL_TRACER].value); |
|
|
@ -458,13 +459,13 @@ class ClientChannel::LoadBalancedCall |
|
|
|
grpc_error_handle* error); |
|
|
|
grpc_error_handle* error); |
|
|
|
// Adds the call to the channel's list of queued picks if not already present.
|
|
|
|
// Adds the call to the channel's list of queued picks if not already present.
|
|
|
|
void AddCallToLbQueuedCallsLocked() |
|
|
|
void AddCallToLbQueuedCallsLocked() |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::lb_mu_); |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_); |
|
|
|
|
|
|
|
|
|
|
|
// Called when adding the call to the LB queue.
|
|
|
|
// Called when adding the call to the LB queue.
|
|
|
|
virtual void OnAddToQueueLocked() |
|
|
|
virtual void OnAddToQueueLocked() |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::lb_mu_) = 0; |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_) = 0; |
|
|
|
|
|
|
|
|
|
|
|
ClientChannel* chand_; |
|
|
|
ClientChannelFilter* chand_; |
|
|
|
|
|
|
|
|
|
|
|
absl::AnyInvocable<void()> on_commit_; |
|
|
|
absl::AnyInvocable<void()> on_commit_; |
|
|
|
|
|
|
|
|
|
|
@ -477,8 +478,8 @@ class ClientChannel::LoadBalancedCall |
|
|
|
grpc_call_context_element* const call_context_; |
|
|
|
grpc_call_context_element* const call_context_; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class ClientChannel::FilterBasedLoadBalancedCall |
|
|
|
class ClientChannelFilter::FilterBasedLoadBalancedCall |
|
|
|
: public ClientChannel::LoadBalancedCall { |
|
|
|
: public ClientChannelFilter::LoadBalancedCall { |
|
|
|
public: |
|
|
|
public: |
|
|
|
// If on_call_destruction_complete is non-null, then it will be
|
|
|
|
// If on_call_destruction_complete is non-null, then it will be
|
|
|
|
// invoked once the LoadBalancedCall is completely destroyed.
|
|
|
|
// invoked once the LoadBalancedCall is completely destroyed.
|
|
|
@ -486,7 +487,7 @@ class ClientChannel::FilterBasedLoadBalancedCall |
|
|
|
// the LB call has a subchannel call and ensuring that the
|
|
|
|
// the LB call has a subchannel call and ensuring that the
|
|
|
|
// on_call_destruction_complete closure passed down from the surface
|
|
|
|
// on_call_destruction_complete closure passed down from the surface
|
|
|
|
// is not invoked until after the subchannel call stack is destroyed.
|
|
|
|
// is not invoked until after the subchannel call stack is destroyed.
|
|
|
|
FilterBasedLoadBalancedCall(ClientChannel* chand, |
|
|
|
FilterBasedLoadBalancedCall(ClientChannelFilter* chand, |
|
|
|
const grpc_call_element_args& args, |
|
|
|
const grpc_call_element_args& args, |
|
|
|
grpc_polling_entity* pollent, |
|
|
|
grpc_polling_entity* pollent, |
|
|
|
grpc_closure* on_call_destruction_complete, |
|
|
|
grpc_closure* on_call_destruction_complete, |
|
|
@ -555,10 +556,10 @@ class ClientChannel::FilterBasedLoadBalancedCall |
|
|
|
void TryPick(bool was_queued); |
|
|
|
void TryPick(bool was_queued); |
|
|
|
|
|
|
|
|
|
|
|
void OnAddToQueueLocked() override |
|
|
|
void OnAddToQueueLocked() override |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::lb_mu_); |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_); |
|
|
|
|
|
|
|
|
|
|
|
void RetryPickLocked() override |
|
|
|
void RetryPickLocked() override |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::lb_mu_); |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_); |
|
|
|
|
|
|
|
|
|
|
|
void CreateSubchannelCall(); |
|
|
|
void CreateSubchannelCall(); |
|
|
|
|
|
|
|
|
|
|
@ -579,9 +580,8 @@ class ClientChannel::FilterBasedLoadBalancedCall |
|
|
|
// Set when we fail inside the LB call.
|
|
|
|
// Set when we fail inside the LB call.
|
|
|
|
grpc_error_handle failure_error_; |
|
|
|
grpc_error_handle failure_error_; |
|
|
|
|
|
|
|
|
|
|
|
// Accessed while holding ClientChannel::lb_mu_.
|
|
|
|
|
|
|
|
LbQueuedCallCanceller* lb_call_canceller_ |
|
|
|
LbQueuedCallCanceller* lb_call_canceller_ |
|
|
|
ABSL_GUARDED_BY(&ClientChannel::lb_mu_) = nullptr; |
|
|
|
ABSL_GUARDED_BY(&ClientChannelFilter::lb_mu_) = nullptr; |
|
|
|
|
|
|
|
|
|
|
|
RefCountedPtr<SubchannelCall> subchannel_call_; |
|
|
|
RefCountedPtr<SubchannelCall> subchannel_call_; |
|
|
|
|
|
|
|
|
|
|
@ -604,10 +604,10 @@ class ClientChannel::FilterBasedLoadBalancedCall |
|
|
|
grpc_transport_stream_op_batch* pending_batches_[MAX_PENDING_BATCHES] = {}; |
|
|
|
grpc_transport_stream_op_batch* pending_batches_[MAX_PENDING_BATCHES] = {}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class ClientChannel::PromiseBasedLoadBalancedCall |
|
|
|
class ClientChannelFilter::PromiseBasedLoadBalancedCall |
|
|
|
: public ClientChannel::LoadBalancedCall { |
|
|
|
: public ClientChannelFilter::LoadBalancedCall { |
|
|
|
public: |
|
|
|
public: |
|
|
|
PromiseBasedLoadBalancedCall(ClientChannel* chand, |
|
|
|
PromiseBasedLoadBalancedCall(ClientChannelFilter* chand, |
|
|
|
absl::AnyInvocable<void()> on_commit, |
|
|
|
absl::AnyInvocable<void()> on_commit, |
|
|
|
bool is_transparent_retry); |
|
|
|
bool is_transparent_retry); |
|
|
|
|
|
|
|
|
|
|
@ -622,7 +622,7 @@ class ClientChannel::PromiseBasedLoadBalancedCall |
|
|
|
void RetryPickLocked() override; |
|
|
|
void RetryPickLocked() override; |
|
|
|
|
|
|
|
|
|
|
|
void OnAddToQueueLocked() override |
|
|
|
void OnAddToQueueLocked() override |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::lb_mu_); |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_); |
|
|
|
|
|
|
|
|
|
|
|
grpc_polling_entity pollent_; |
|
|
|
grpc_polling_entity pollent_; |
|
|
|
ClientMetadataHandle client_initial_metadata_; |
|
|
|
ClientMetadataHandle client_initial_metadata_; |
|
|
|