19 #ifndef GRPCXX_CHANNEL_FILTER_H
20 #define GRPCXX_CHANNEL_FILTER_H
85 return elem_ == other.elem_;
88 return elem_ != other.elem_;
135 send_initial_metadata_(
139 send_trailing_metadata_(
143 recv_initial_metadata_(
147 recv_trailing_metadata_(
172 .send_initial_metadata_flags
206 return static_cast<census_context*
>(
286 template <
typename ChannelDataType,
typename CallDataType>
294 ChannelDataType* channel_data =
new (elem->
channel_data) ChannelDataType();
295 return channel_data->Init(elem, args);
299 ChannelDataType* channel_data =
301 channel_data->Destroy(elem);
302 channel_data->~ChannelDataType();
307 ChannelDataType* channel_data =
310 channel_data->StartTransportOp(elem, &op_wrapper);
315 ChannelDataType* channel_data =
317 channel_data->GetInfo(elem, channel_info);
325 CallDataType* call_data =
new (elem->
call_data) CallDataType();
326 return call_data->Init(elem, args);
332 CallDataType* call_data =
static_cast<CallDataType*
>(elem->
call_data);
333 call_data->Destroy(elem, final_info, then_call_closure);
334 call_data->~CallDataType();
339 CallDataType* call_data =
static_cast<CallDataType*
>(elem->
call_data);
341 call_data->StartTransportStreamOpBatch(elem, &op_wrapper);
346 CallDataType* call_data =
static_cast<CallDataType*
>(elem->
call_data);
347 call_data->SetPollsetOrPollsetSet(elem, pollent);
374 template <
typename ChannelDataType,
typename CallDataType>
392 {FilterType::StartTransportStreamOpBatch, FilterType::StartTransportOp,
393 FilterType::call_data_size, FilterType::InitCallElement,
394 FilterType::SetPollsetOrPollsetSet, FilterType::DestroyCallElement,
395 FilterType::channel_data_size, FilterType::InitChannelElement,
396 FilterType::DestroyChannelElement, FilterType::GetChannelInfo, name}};
grpc_channel_stack_type
Definition: channel_stack_type.h:26
Represents call data.
Definition: channel_filter.h:254
virtual grpc_error * Init(grpc_call_element *, const grpc_call_element_args *)
Initializes the call data.
Definition: channel_filter.h:262
virtual void SetPollsetOrPollsetSet(grpc_call_element *elem, grpc_polling_entity *pollent)
Sets a pollset or pollset set.
Definition: channel_filter.cc:59
virtual void Destroy(grpc_call_element *, const grpc_call_final_info *, grpc_closure *)
Definition: channel_filter.h:268
virtual void StartTransportStreamOpBatch(grpc_call_element *elem, TransportStreamOpBatch *op)
Starts a new stream operation.
Definition: channel_filter.cc:54
CallData()
Definition: channel_filter.h:256
virtual ~CallData()
Definition: channel_filter.h:257
Represents channel data.
Definition: channel_filter.h:231
ChannelData()
Definition: channel_filter.h:233
virtual grpc_error * Init(grpc_channel_element *, grpc_channel_element_args *)
Initializes the channel data.
Definition: channel_filter.h:239
virtual void GetInfo(grpc_channel_element *elem, const grpc_channel_info *channel_info)
Definition: channel_filter.cc:47
virtual void StartTransportOp(grpc_channel_element *elem, TransportOp *op)
Definition: channel_filter.cc:42
virtual void Destroy(grpc_channel_element *)
Definition: channel_filter.h:245
virtual ~ChannelData()
Definition: channel_filter.h:234
A C++ wrapper for the grpc_transport_op struct.
Definition: channel_filter.h:106
TransportOp(grpc_transport_op *op)
Borrows a pointer to op, but does NOT take ownership.
Definition: channel_filter.h:111
grpc_error * disconnect_with_error() const
Definition: channel_filter.h:116
grpc_transport_op * op() const
Definition: channel_filter.h:113
bool send_goaway() const
Definition: channel_filter.h:119
A C++ wrapper for the grpc_transport_stream_op_batch struct.
Definition: channel_filter.h:128
TransportStreamOpBatch(grpc_transport_stream_op_batch *op)
Borrows a pointer to op, but does NOT take ownership.
Definition: channel_filter.h:133
grpc_transport_stream_op_batch * op() const
Definition: channel_filter.h:152
void set_recv_message(grpc_core::OrphanablePtr< grpc_core::ByteStream > *recv_message)
Definition: channel_filter.h:199
grpc_core::OrphanablePtr< grpc_core::ByteStream > * send_message() const
Definition: channel_filter.h:185
uint32_t * send_initial_metadata_flags() const
Definition: channel_filter.h:170
grpc_core::OrphanablePtr< grpc_core::ByteStream > * recv_message() const
Definition: channel_filter.h:195
MetadataBatch * recv_initial_metadata()
Definition: channel_filter.h:163
void set_recv_initial_metadata_ready(grpc_closure *closure)
Definition: channel_filter.h:181
void set_on_complete(grpc_closure *closure)
Definition: channel_filter.h:155
census_context * get_census_context() const
Definition: channel_filter.h:205
void set_send_message(grpc_core::OrphanablePtr< grpc_core::ByteStream > send_message)
Definition: channel_filter.h:189
MetadataBatch * send_trailing_metadata()
Definition: channel_filter.h:160
const gpr_atm * get_peer_string() const
Definition: channel_filter.h:210
MetadataBatch * recv_trailing_metadata()
Definition: channel_filter.h:166
grpc_closure * on_complete() const
Definition: channel_filter.h:154
MetadataBatch * send_initial_metadata()
Definition: channel_filter.h:157
grpc_closure * recv_initial_metadata_ready() const
Definition: channel_filter.h:176
Definition: channel_filter.h:287
static void DestroyChannelElement(grpc_channel_element *elem)
Definition: channel_filter.h:298
static void StartTransportOp(grpc_channel_element *elem, grpc_transport_op *op)
Definition: channel_filter.h:305
static grpc_error * InitChannelElement(grpc_channel_element *elem, grpc_channel_element_args *args)
Definition: channel_filter.h:291
static const size_t call_data_size
Definition: channel_filter.h:320
static void DestroyCallElement(grpc_call_element *elem, const grpc_call_final_info *final_info, grpc_closure *then_call_closure)
Definition: channel_filter.h:329
static grpc_error * InitCallElement(grpc_call_element *elem, const grpc_call_element_args *args)
Definition: channel_filter.h:322
static void StartTransportStreamOpBatch(grpc_call_element *elem, grpc_transport_stream_op_batch *op)
Definition: channel_filter.h:337
static const size_t channel_data_size
Definition: channel_filter.h:289
static void SetPollsetOrPollsetSet(grpc_call_element *elem, grpc_polling_entity *pollent)
Definition: channel_filter.h:344
static void GetChannelInfo(grpc_channel_element *elem, const grpc_channel_info *channel_info)
Definition: channel_filter.h:313
@ GRPC_CONTEXT_TRACING
Value is a census_context.
Definition: context.h:33
#define GRPC_ERROR_NONE
The following "special" errors can be propagated without allocating memory.
Definition: error.h:125
GRPCAPI void grpc_register_plugin(void(*init)(void), void(*destroy)(void))
Registers a plugin to be initialized and destroyed with the library.
intptr_t gpr_atm
Definition: atm_gcc_atomic.h:30
std::vector< FilterRecord > * channel_filters
Definition: channel_filter.cc:69
void ChannelFilterPluginShutdown()
Definition: channel_filter.cc:94
void ChannelFilterPluginInit()
Definition: channel_filter.cc:86
std::unique_ptr< T, Deleter > OrphanablePtr
Definition: orphanable.h:68
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
void RegisterChannelFilter(const char *name, grpc_channel_stack_type stack_type, int priority, std::function< bool(const grpc_channel_args &)> include_filter)
Registers a new filter.
Definition: channel_filter.h:375
Definition: channel_filter.h:351
grpc_channel_filter filter
Definition: channel_filter.h:355
int priority
Definition: channel_filter.h:353
std::function< bool(const grpc_channel_args &)> include_filter
Definition: channel_filter.h:354
grpc_channel_stack_type stack_type
Definition: channel_filter.h:352
void * value
Definition: context.h:45
Definition: channel_stack.h:66
Definition: channel_stack.h:167
void * call_data
Definition: channel_stack.h:170
Information about the call upon completion.
Definition: channel_stack.h:83
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Definition: channel_stack.h:57
Definition: channel_stack.h:159
void * channel_data
Definition: channel_stack.h:161
Definition: channel_stack.h:99
Information requested from the channel.
Definition: grpc_types.h:668
A closure over a grpc_iomgr_cb_func.
Definition: closure.h:56
Definition: error_internal.h:39
Definition: metadata_batch.h:33
struct grpc_linked_mdelem * prev
Definition: metadata_batch.h:38
grpc_mdelem md
Definition: metadata_batch.h:36
struct grpc_linked_mdelem * next
Definition: metadata_batch.h:37
grpc_linked_mdelem * head
Definition: metadata_batch.h:45
Definition: metadata.h:98
Definition: polling_entity.h:37
Transport op: a set of operations to perform on a transport as a whole.
Definition: transport.h:324
grpc_error * disconnect_with_error
should the transport be disconnected Error contract: the transport that gets this op must cause disco...
Definition: transport.h:336
grpc_error * goaway_error
what should the goaway contain? Error contract: the transport that gets this op must cause goaway_err...
Definition: transport.h:340
grpc_metadata_batch * recv_initial_metadata
Definition: transport.h:268
grpc_core::OrphanablePtr< grpc_core::ByteStream > send_message
Definition: transport.h:252
grpc_core::OrphanablePtr< grpc_core::ByteStream > * recv_message
Definition: transport.h:291
grpc_metadata_batch * send_initial_metadata
Definition: transport.h:231
grpc_call_context_element * context
Definition: transport.h:320
Definition: transport.h:163
grpc_transport_stream_op_batch_payload * payload
Values for the stream op (fields set are determined by flags above)
Definition: transport.h:186
bool recv_message
Receive message data from the stream, into provided byte stream.
Definition: transport.h:201
bool recv_trailing_metadata
Receive trailing metadata from the stream, into provided metadata batch.
Definition: transport.h:205
grpc_closure * on_complete
Should be scheduled when all of the non-recv operations in the batch are complete.
Definition: transport.h:183
bool send_trailing_metadata
Send trailing metadata to the peer, from the provided metadata batch.
Definition: transport.h:192
bool send_message
Send message data to the peer, from the provided byte stream.
Definition: transport.h:195
bool send_initial_metadata
Send initial metadata to the peer, from the provided metadata batch.
Definition: transport.h:189
bool recv_initial_metadata
Receive initial metadata from the stream, into provided metadata batch.
Definition: transport.h:198