aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2018-10-22 02:42:03 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2018-10-22 02:42:03 -0700
commit9b83b7d19e0a3e14dbfca2f40fa8157547c190f4 (patch)
tree8e48f2a77de1b44cd9415f5d6b11aa452095861d /src/cpp
parent3a17f5b05ec6adce638fd03168a923e727759969 (diff)
Adding intercepted channel
Diffstat (limited to 'src/cpp')
-rw-r--r--src/cpp/client/channel_cc.cc17
-rw-r--r--src/cpp/client/intercepted_channel.cc33
-rw-r--r--src/cpp/server/server_cc.cc9
3 files changed, 49 insertions, 10 deletions
diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc
index 12ff20c7ea..f2a2a2fdc9 100644
--- a/src/cpp/client/channel_cc.cc
+++ b/src/cpp/client/channel_cc.cc
@@ -111,9 +111,10 @@ void ChannelResetConnectionBackoff(Channel* channel) {
} // namespace experimental
-internal::Call Channel::CreateCall(const internal::RpcMethod& method,
- ClientContext* context,
- CompletionQueue* cq) {
+internal::Call Channel::CreateCallInternal(const internal::RpcMethod& method,
+ ClientContext* context,
+ CompletionQueue* cq,
+ int interceptor_pos) {
const bool kRegistered = method.channel_tag() && context->authority().empty();
grpc_call* c_call = nullptr;
if (kRegistered) {
@@ -147,11 +148,17 @@ internal::Call Channel::CreateCall(const internal::RpcMethod& method,
grpc_census_call_set_context(c_call, context->census_context());
context->set_call(c_call, shared_from_this());
- auto* info = context->set_client_rpc_info(experimental::ClientRpcInfo(
- context, method.name(), this, interceptor_creators_));
+ auto* info = context->set_client_rpc_info(
+ method.name(), this, interceptor_creators_, interceptor_pos);
return internal::Call(c_call, this, cq, info);
}
+internal::Call Channel::CreateCall(const internal::RpcMethod& method,
+ ClientContext* context,
+ CompletionQueue* cq) {
+ return CreateCallInternal(method, context, cq, 0);
+}
+
void Channel::PerformOpsOnCall(internal::CallOpSetInterface* ops,
internal::Call* call) {
ops->FillOps(
diff --git a/src/cpp/client/intercepted_channel.cc b/src/cpp/client/intercepted_channel.cc
new file mode 100644
index 0000000000..48e9b8c218
--- /dev/null
+++ b/src/cpp/client/intercepted_channel.cc
@@ -0,0 +1,33 @@
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpcpp/impl/codegen/intercepted_channel.h>
+
+#include <grpcpp/channel.h>
+
+namespace grpc {
+namespace internal {
+
+internal::Call InterceptedChannel::CreateCall(const internal::RpcMethod& method,
+ ClientContext* context,
+ CompletionQueue* cq) {
+ return (dynamic_cast<Channel*>(channel_))
+ ->CreateCallInternal(method, context, cq, interceptor_pos_);
+}
+} // namespace internal
+} // namespace grpc
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index 5124044a8b..bdf4824ca7 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -218,8 +218,8 @@ class Server::SyncRequest final : public internal::CompletionQueueTag {
request_(nullptr),
method_(mrd->method_),
call_(mrd->call_, server, &cq_, server->max_receive_message_size(),
- ctx_.set_server_rpc_info(experimental::ServerRpcInfo(
- &ctx_, method_->name(), server->interceptor_creators_))),
+ ctx_.set_server_rpc_info(method_->name(),
+ server->interceptor_creators_)),
server_(server),
global_callbacks_(nullptr),
resources_(false) {
@@ -859,10 +859,9 @@ bool ServerInterface::GenericAsyncRequest::FinalizeResult(void** tag,
grpc_slice_unref(call_details_.host);
call_wrapper_ = internal::Call(
call_, server_, call_cq_, server_->max_receive_message_size(),
- context_->set_server_rpc_info(experimental::ServerRpcInfo(
- context_,
+ context_->set_server_rpc_info(
static_cast<GenericServerContext*>(context_)->method_.c_str(),
- *server_->interceptor_creators())));
+ *server_->interceptor_creators()));
return BaseAsyncRequest::FinalizeResult(tag, status);
}