aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/common
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-11-08 10:45:21 -0800
committerGravatar GitHub <noreply@github.com>2016-11-08 10:45:21 -0800
commit0ace62f83200a881545daa619eed08cbd431ea5f (patch)
tree8c7e36380b7b92bd56d6962a597bb64acac5163e /src/cpp/common
parenta987041a27c36089f76549ba86a1da4edb322959 (diff)
parentc00688da74f3f37c7bb8f9a831940fa58e23f460 (diff)
Merge pull request #8618 from markdroth/channel_info_api
Add API for getting arbitrary state back from a channel
Diffstat (limited to 'src/cpp/common')
-rw-r--r--src/cpp/common/channel_filter.cc5
-rw-r--r--src/cpp/common/channel_filter.h14
2 files changed, 18 insertions, 1 deletions
diff --git a/src/cpp/common/channel_filter.cc b/src/cpp/common/channel_filter.cc
index 25cd49cb7c..ad2c0f2295 100644
--- a/src/cpp/common/channel_filter.cc
+++ b/src/cpp/common/channel_filter.cc
@@ -57,6 +57,11 @@ void ChannelData::StartTransportOp(grpc_exec_ctx *exec_ctx,
grpc_channel_next_op(exec_ctx, elem, op->op());
}
+void ChannelData::GetInfo(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
+ const grpc_channel_info *channel_info) {
+ grpc_channel_next_get_info(exec_ctx, elem, channel_info);
+}
+
// CallData
void CallData::StartTransportStreamOp(grpc_exec_ctx *exec_ctx,
diff --git a/src/cpp/common/channel_filter.h b/src/cpp/common/channel_filter.h
index fc0deff3b3..e420efc71c 100644
--- a/src/cpp/common/channel_filter.h
+++ b/src/cpp/common/channel_filter.h
@@ -224,9 +224,13 @@ class ChannelData {
const char *peer() const { return peer_; }
// TODO(roth): Find a way to avoid passing elem into these methods.
+
virtual void StartTransportOp(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem, TransportOp *op);
+ virtual void GetInfo(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
+ const grpc_channel_info *channel_info);
+
protected:
/// Takes ownership of \a peer.
ChannelData(const grpc_channel_args &args, const char *peer) : peer_(peer) {}
@@ -296,6 +300,13 @@ class ChannelFilter final {
channel_data->StartTransportOp(exec_ctx, elem, &op_wrapper);
}
+ static void GetChannelInfo(grpc_exec_ctx *exec_ctx,
+ grpc_channel_element *elem,
+ const grpc_channel_info *channel_info) {
+ ChannelDataType *channel_data = (ChannelDataType *)elem->channel_data;
+ channel_data->GetInfo(exec_ctx, elem, channel_info);
+ }
+
static const size_t call_data_size = sizeof(CallDataType);
static grpc_error *InitCallElement(grpc_exec_ctx *exec_ctx,
@@ -376,7 +387,8 @@ void RegisterChannelFilter(
FilterType::call_data_size, FilterType::InitCallElement,
FilterType::SetPollsetOrPollsetSet, FilterType::DestroyCallElement,
FilterType::channel_data_size, FilterType::InitChannelElement,
- FilterType::DestroyChannelElement, FilterType::GetPeer, name}};
+ FilterType::DestroyChannelElement, FilterType::GetPeer,
+ FilterType::GetChannelInfo, name}};
internal::channel_filters->push_back(filter_record);
}