aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/client/client_context.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpp/client/client_context.cc')
-rw-r--r--src/cpp/client/client_context.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index f38a694734..72cdd49d19 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -34,6 +34,7 @@
#include <grpc++/client_context.h>
#include <grpc/grpc.h>
+#include <grpc++/credentials.h>
#include <grpc++/time.h>
namespace grpc {
@@ -63,6 +64,17 @@ void ClientContext::AddMetadata(const grpc::string& meta_key,
send_initial_metadata_.insert(std::make_pair(meta_key, meta_value));
}
+void ClientContext::set_call(grpc_call* call,
+ const std::shared_ptr<ChannelInterface>& channel) {
+ GPR_ASSERT(call_ == nullptr);
+ call_ = call;
+ channel_ = channel;
+ if (creds_ && !creds_->ApplyToCall(call_)) {
+ grpc_call_cancel_with_status(call, GRPC_STATUS_CANCELLED,
+ "Failed to set credentials to rpc.");
+ }
+}
+
void ClientContext::TryCancel() {
if (call_) {
grpc_call_cancel(call_);