aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-06-16 14:52:41 -0700
committerGravatar Mark D. Roth <roth@google.com>2016-06-16 14:52:41 -0700
commit035cb3a3d4fe9634834b5814827e49adc9cf6b69 (patch)
tree865354cf9bc552ff2321cb158fdb259c9a191ba5 /include
parent9fe5ef5f9d17289f57ee1d5436314c3153b80975 (diff)
Pass peer string to ChannelData ctor when available.
Diffstat (limited to 'include')
-rw-r--r--include/grpc++/channel_filter.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/include/grpc++/channel_filter.h b/include/grpc++/channel_filter.h
index 542e6a0f35..53e42a7cb8 100644
--- a/include/grpc++/channel_filter.h
+++ b/include/grpc++/channel_filter.h
@@ -62,8 +62,13 @@ class ChannelData {
grpc_channel_element *elem,
grpc_transport_op *op);
+ const char* peer() const { return peer_; }
+
protected:
- explicit ChannelData(const grpc_channel_args &) {}
+ ChannelData(const grpc_channel_args &args, const char *peer) : peer_(peer) {}
+
+ private:
+ const char *peer_; // Do not own.
};
// Represents call data.
@@ -96,8 +101,12 @@ class ChannelFilter {
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)
+ : nullptr;
// Construct the object in the already-allocated memory.
- new (elem->channel_data) ChannelDataType(*args->channel_args);
+ new (elem->channel_data) ChannelDataType(*args->channel_args, peer);
}
static void DestroyChannelElement(grpc_exec_ctx *exec_ctx,