aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/client
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2015-08-06 22:51:27 -0700
committerGravatar yang-g <yangg@google.com>2015-08-06 22:51:27 -0700
commit87e133e13ae06ef5d1752cf37a473896ddf555cb (patch)
tree5bb0c0ef8221fb51914e7c146751280f4f5ef7df /src/cpp/client
parentc8abca8f5311832f41751ab11bb2365f9e348ad8 (diff)
parent03b19118e349ca480f2739ed6efd00ba7be4cf45 (diff)
merge with head
Diffstat (limited to 'src/cpp/client')
-rw-r--r--src/cpp/client/channel.cc22
-rw-r--r--src/cpp/client/client_context.cc12
2 files changed, 23 insertions, 11 deletions
diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc
index 8bda1f473f..af7366eb01 100644
--- a/src/cpp/client/channel.cc
+++ b/src/cpp/client/channel.cc
@@ -62,16 +62,18 @@ Channel::~Channel() { grpc_channel_destroy(c_channel_); }
Call Channel::CreateCall(const RpcMethod& method, ClientContext* context,
CompletionQueue* cq) {
const char* host_str = host_.empty() ? NULL : host_.c_str();
- auto c_call =
- method.channel_tag() && context->authority().empty()
- ? grpc_channel_create_registered_call(c_channel_, cq->cq(),
- method.channel_tag(),
- context->raw_deadline())
- : grpc_channel_create_call(c_channel_, cq->cq(), method.name(),
- context->authority().empty()
- ? host_str
- : context->authority().c_str(),
- context->raw_deadline());
+ auto c_call = method.channel_tag() && context->authority().empty()
+ ? grpc_channel_create_registered_call(
+ c_channel_, context->propagate_from_call_,
+ context->propagation_options_.c_bitmask(), cq->cq(),
+ method.channel_tag(), context->raw_deadline())
+ : grpc_channel_create_call(
+ c_channel_, context->propagate_from_call_,
+ context->propagation_options_.c_bitmask(), cq->cq(),
+ method.name(), context->authority().empty()
+ ? host_str
+ : context->authority().c_str(),
+ context->raw_deadline());
grpc_census_call_set_context(c_call, context->census_context());
GRPC_TIMER_MARK(GRPC_PTAG_CPP_CALL_CREATED, c_call);
context->set_call(c_call, shared_from_this());
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index c38d0c1df6..1ed2d38961 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -37,6 +37,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include <grpc++/credentials.h>
+#include <grpc++/server_context.h>
#include <grpc++/time.h>
#include "src/core/channel/compress_filter.h"
@@ -48,7 +49,8 @@ ClientContext::ClientContext()
: initial_metadata_received_(false),
call_(nullptr),
cq_(nullptr),
- deadline_(gpr_inf_future(GPR_CLOCK_REALTIME)) {}
+ deadline_(gpr_inf_future(GPR_CLOCK_REALTIME)),
+ propagate_from_call_(nullptr) {}
ClientContext::~ClientContext() {
if (call_) {
@@ -64,6 +66,14 @@ ClientContext::~ClientContext() {
}
}
+std::unique_ptr<ClientContext> ClientContext::FromServerContext(
+ const ServerContext& context, PropagationOptions options) {
+ std::unique_ptr<ClientContext> ctx(new ClientContext);
+ ctx->propagate_from_call_ = context.call_;
+ ctx->propagation_options_ = options;
+ return ctx;
+}
+
void ClientContext::AddMetadata(const grpc::string& meta_key,
const grpc::string& meta_value) {
send_initial_metadata_.insert(std::make_pair(meta_key, meta_value));