aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/client/channel.cc
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-02-21 22:45:35 -0800
committerGravatar Craig Tiller <ctiller@google.com>2015-02-23 09:58:22 -0800
commit47c83fdaf71ca5072d0ab37322b37586d23f5ceb (patch)
tree808ca8183045d5e770eebe4eee31ca907ead1f56 /src/cpp/client/channel.cc
parent8b131922438d96579cb315777ca980e094883496 (diff)
Credentials prototyping
- Remove CredentialsFactory as it's unnecessary - Effectively make Credentials a channel factory, allowing different credential types to create different channel types - this gives us a hook so that InsecureCredentials can at runtime instantiate a different kind of channel as required - giving us a way of generating an openssl free version of grpc++. - Server credentials not touched yet, but they'll need to be updated.
Diffstat (limited to 'src/cpp/client/channel.cc')
-rw-r--r--src/cpp/client/channel.cc40
1 files changed, 10 insertions, 30 deletions
diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc
index ca69d66cbb..65bd135d5c 100644
--- a/src/cpp/client/channel.cc
+++ b/src/cpp/client/channel.cc
@@ -54,43 +54,23 @@
namespace grpc {
-Channel::Channel(const grpc::string &target, const ChannelArguments &args)
- : target_(target) {
- grpc_channel_args channel_args;
- args.SetChannelArgs(&channel_args);
- c_channel_ = grpc_channel_create(
- target_.c_str(), channel_args.num_args > 0 ? &channel_args : nullptr);
-}
-
-Channel::Channel(const grpc::string &target,
- const std::unique_ptr<Credentials> &creds,
- const ChannelArguments &args)
- : target_(args.GetSslTargetNameOverride().empty()
- ? target
- : args.GetSslTargetNameOverride()) {
- grpc_channel_args channel_args;
- args.SetChannelArgs(&channel_args);
- grpc_credentials *c_creds = creds ? creds->GetRawCreds() : nullptr;
- c_channel_ = grpc_secure_channel_create(
- c_creds, target.c_str(),
- channel_args.num_args > 0 ? &channel_args : nullptr);
-}
+Channel::Channel(const grpc::string& target, grpc_channel* channel)
+ : target_(target), c_channel_(channel) {}
Channel::~Channel() { grpc_channel_destroy(c_channel_); }
-Call Channel::CreateCall(const RpcMethod &method, ClientContext *context,
- CompletionQueue *cq) {
- auto c_call =
- grpc_channel_create_call(
- c_channel_, cq->cq(), method.name(),
- context->authority().empty() ? target_.c_str()
- : context->authority().c_str(),
- context->RawDeadline());
+Call Channel::CreateCall(const RpcMethod& method, ClientContext* context,
+ CompletionQueue* cq) {
+ auto c_call = grpc_channel_create_call(c_channel_, cq->cq(), method.name(),
+ context->authority().empty()
+ ? target_.c_str()
+ : context->authority().c_str(),
+ context->RawDeadline());
context->set_call(c_call);
return Call(c_call, this, cq);
}
-void Channel::PerformOpsOnCall(CallOpBuffer *buf, Call *call) {
+void Channel::PerformOpsOnCall(CallOpBuffer* buf, Call* call) {
static const size_t MAX_OPS = 8;
size_t nops = MAX_OPS;
grpc_op ops[MAX_OPS];