aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpp/client')
-rw-r--r--src/cpp/client/channel.cc12
-rw-r--r--src/cpp/client/channel.h5
-rw-r--r--src/cpp/client/create_channel.cc4
-rw-r--r--src/cpp/client/insecure_credentials.cc2
-rw-r--r--src/cpp/client/secure_credentials.cc3
5 files changed, 15 insertions, 11 deletions
diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc
index 5df81e641e..ee143d68a0 100644
--- a/src/cpp/client/channel.cc
+++ b/src/cpp/client/channel.cc
@@ -51,13 +51,16 @@
namespace grpc {
-Channel::Channel(const grpc::string& target, grpc_channel* channel)
- : target_(target), c_channel_(channel) {}
+Channel::Channel(grpc_channel* channel) : c_channel_(channel) {}
+
+Channel::Channel(const grpc::string& host, grpc_channel* channel)
+ : host_(host), c_channel_(channel) {}
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(),
@@ -65,7 +68,7 @@ Call Channel::CreateCall(const RpcMethod& method, ClientContext* context,
context->raw_deadline())
: grpc_channel_create_call(c_channel_, cq->cq(), method.name(),
context->authority().empty()
- ? target_.c_str()
+ ? host_str
: context->authority().c_str(),
context->raw_deadline());
grpc_census_call_set_context(c_call, context->census_context());
@@ -86,7 +89,8 @@ void Channel::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) {
}
void* Channel::RegisterMethod(const char* method) {
- return grpc_channel_register_call(c_channel_, method, target_.c_str());
+ return grpc_channel_register_call(c_channel_, method,
+ host_.empty() ? NULL : host_.c_str());
}
} // namespace grpc
diff --git a/src/cpp/client/channel.h b/src/cpp/client/channel.h
index 9108713c58..8660146856 100644
--- a/src/cpp/client/channel.h
+++ b/src/cpp/client/channel.h
@@ -52,7 +52,8 @@ class StreamContextInterface;
class Channel GRPC_FINAL : public GrpcLibrary, public ChannelInterface {
public:
- Channel(const grpc::string& target, grpc_channel* c_channel);
+ explicit Channel(grpc_channel* c_channel);
+ Channel(const grpc::string& host, grpc_channel* c_channel);
~Channel() GRPC_OVERRIDE;
virtual void* RegisterMethod(const char* method) GRPC_OVERRIDE;
@@ -62,7 +63,7 @@ class Channel GRPC_FINAL : public GrpcLibrary, public ChannelInterface {
Call* call) GRPC_OVERRIDE;
private:
- const grpc::string target_;
+ const grpc::string host_;
grpc_channel* const c_channel_; // owned
};
diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc
index dbe2694a78..21d01b739d 100644
--- a/src/cpp/client/create_channel.cc
+++ b/src/cpp/client/create_channel.cc
@@ -51,7 +51,7 @@ std::shared_ptr<ChannelInterface> CreateChannel(
cp_args.SetString(GRPC_ARG_PRIMARY_USER_AGENT_STRING,
user_agent_prefix.str());
return creds ? creds->CreateChannel(target, cp_args)
- : std::shared_ptr<ChannelInterface>(new Channel(
- target, grpc_lame_client_channel_create(NULL)));
+ : std::shared_ptr<ChannelInterface>(
+ new Channel(grpc_lame_client_channel_create(NULL)));
}
} // namespace grpc
diff --git a/src/cpp/client/insecure_credentials.cc b/src/cpp/client/insecure_credentials.cc
index e802fa8034..d8dcaa1436 100644
--- a/src/cpp/client/insecure_credentials.cc
+++ b/src/cpp/client/insecure_credentials.cc
@@ -49,7 +49,7 @@ class InsecureCredentialsImpl GRPC_FINAL : public Credentials {
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
return std::shared_ptr<ChannelInterface>(new Channel(
- target, grpc_insecure_channel_create(target.c_str(), &channel_args)));
+ grpc_insecure_channel_create(target.c_str(), &channel_args)));
}
// InsecureCredentials should not be applied to a call.
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index abf0cb387e..2d6114e06b 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -44,8 +44,7 @@ std::shared_ptr<grpc::ChannelInterface> SecureCredentials::CreateChannel(
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
return std::shared_ptr<ChannelInterface>(new Channel(
- args.GetSslTargetNameOverride().empty() ? target
- : args.GetSslTargetNameOverride(),
+ args.GetSslTargetNameOverride(),
grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args)));
}