|
|
|
@ -34,9 +34,9 @@ |
|
|
|
|
#ifndef GRPCXX_CHANNEL_FILTER_H |
|
|
|
|
#define GRPCXX_CHANNEL_FILTER_H |
|
|
|
|
|
|
|
|
|
#include <grpc/grpc.h> |
|
|
|
|
#include <grpc/census.h> |
|
|
|
|
#include <grpc++/impl/codegen/config.h> |
|
|
|
|
#include <grpc/census.h> |
|
|
|
|
#include <grpc/grpc.h> |
|
|
|
|
|
|
|
|
|
#include <functional> |
|
|
|
|
#include <vector> |
|
|
|
@ -147,25 +147,23 @@ class TransportStreamOp { |
|
|
|
|
grpc_transport_stream_op *op() const { return op_; } |
|
|
|
|
|
|
|
|
|
grpc_closure *on_complete() const { return op_->on_complete; } |
|
|
|
|
void set_on_complete(grpc_closure* closure) { |
|
|
|
|
op_->on_complete = closure; |
|
|
|
|
} |
|
|
|
|
void set_on_complete(grpc_closure *closure) { op_->on_complete = closure; } |
|
|
|
|
|
|
|
|
|
MetadataBatch *send_initial_metadata() { |
|
|
|
|
return op_->send_initial_metadata == nullptr |
|
|
|
|
? nullptr : &send_initial_metadata_; |
|
|
|
|
return op_->send_initial_metadata == nullptr ? nullptr |
|
|
|
|
: &send_initial_metadata_; |
|
|
|
|
} |
|
|
|
|
MetadataBatch *send_trailing_metadata() { |
|
|
|
|
return op_->send_trailing_metadata == nullptr |
|
|
|
|
? nullptr : &send_trailing_metadata_; |
|
|
|
|
return op_->send_trailing_metadata == nullptr ? nullptr |
|
|
|
|
: &send_trailing_metadata_; |
|
|
|
|
} |
|
|
|
|
MetadataBatch *recv_initial_metadata() { |
|
|
|
|
return op_->recv_initial_metadata == nullptr |
|
|
|
|
? nullptr : &recv_initial_metadata_; |
|
|
|
|
return op_->recv_initial_metadata == nullptr ? nullptr |
|
|
|
|
: &recv_initial_metadata_; |
|
|
|
|
} |
|
|
|
|
MetadataBatch *recv_trailing_metadata() { |
|
|
|
|
return op_->recv_trailing_metadata == nullptr |
|
|
|
|
? nullptr : &recv_trailing_metadata_; |
|
|
|
|
return op_->recv_trailing_metadata == nullptr ? nullptr |
|
|
|
|
: &recv_trailing_metadata_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint32_t *send_initial_metadata_flags() const { |
|
|
|
@ -186,12 +184,12 @@ class TransportStreamOp { |
|
|
|
|
|
|
|
|
|
// To be called only on clients and servers, respectively.
|
|
|
|
|
grpc_client_security_context *client_security_context() const { |
|
|
|
|
return (grpc_client_security_context*)op_->context[ |
|
|
|
|
GRPC_CONTEXT_SECURITY].value; |
|
|
|
|
return (grpc_client_security_context *)op_->context[GRPC_CONTEXT_SECURITY] |
|
|
|
|
.value; |
|
|
|
|
} |
|
|
|
|
grpc_server_security_context *server_security_context() const { |
|
|
|
|
return (grpc_server_security_context*)op_->context[ |
|
|
|
|
GRPC_CONTEXT_SECURITY].value; |
|
|
|
|
return (grpc_server_security_context *)op_->context[GRPC_CONTEXT_SECURITY] |
|
|
|
|
.value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
census_context *get_census_context() const { |
|
|
|
@ -216,8 +214,7 @@ class ChannelData { |
|
|
|
|
// FIXME: find a way to avoid passing elem into these methods
|
|
|
|
|
// (same for CallData below)
|
|
|
|
|
virtual void StartTransportOp(grpc_exec_ctx *exec_ctx, |
|
|
|
|
grpc_channel_element *elem, |
|
|
|
|
TransportOp *op); |
|
|
|
|
grpc_channel_element *elem, TransportOp *op); |
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
ChannelData(const grpc_channel_args &args, const char *peer) : peer_(peer) {} |
|
|
|
@ -258,9 +255,9 @@ class ChannelFilter GRPC_FINAL { |
|
|
|
|
static void InitChannelElement(grpc_exec_ctx *exec_ctx, |
|
|
|
|
grpc_channel_element *elem, |
|
|
|
|
grpc_channel_element_args *args) { |
|
|
|
|
const char* peer = args->optional_transport |
|
|
|
|
? grpc_transport_get_peer(exec_ctx, |
|
|
|
|
args->optional_transport) |
|
|
|
|
const char *peer = |
|
|
|
|
args->optional_transport |
|
|
|
|
? grpc_transport_get_peer(exec_ctx, args->optional_transport) |
|
|
|
|
: nullptr; |
|
|
|
|
// Construct the object in the already-allocated memory.
|
|
|
|
|
new (elem->channel_data) ChannelDataType(*args->channel_args, peer); |
|
|
|
|