aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar David G. Quintas <dgq@google.com>2015-08-24 15:45:15 -0700
committerGravatar David G. Quintas <dgq@google.com>2015-08-24 15:45:15 -0700
commit045c12a5c6747124efb409952c27a2b1307394bc (patch)
treecd0cc4c262057e8e7c42a463c3ca4c90ba788f1e /src
parent8c4549aec780e2cdeb72f028d9a44ad9fd853c33 (diff)
parentb1f24078338108a0b741a342e4916731f01b2601 (diff)
Merge pull request #3008 from yang-g/docs
Remove ChannelInterface and replace it with Channel
Diffstat (limited to 'src')
-rw-r--r--src/compiler/cpp_generator.cc65
-rw-r--r--src/cpp/client/channel.cc4
-rw-r--r--src/cpp/client/client_context.cc2
-rw-r--r--src/cpp/client/create_channel.cc17
-rw-r--r--src/cpp/client/create_channel_internal.cc (renamed from src/cpp/client/internal_stub.cc)14
-rw-r--r--src/cpp/client/create_channel_internal.h (renamed from src/cpp/client/channel.h)41
-rw-r--r--src/cpp/client/generic_stub.cc3
-rw-r--r--src/cpp/client/insecure_credentials.cc10
-rw-r--r--src/cpp/client/secure_credentials.cc10
-rw-r--r--src/cpp/client/secure_credentials.h2
-rw-r--r--src/cpp/common/call.cc2
11 files changed, 74 insertions, 96 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index ea487bcd89..b04ac038ad 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -112,7 +112,6 @@ grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file,
grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) {
grpc::string temp =
- "#include <grpc++/impl/internal_stub.h>\n"
"#include <grpc++/impl/rpc_method.h>\n"
"#include <grpc++/impl/proto_utils.h>\n"
"#include <grpc++/impl/service_type.h>\n"
@@ -123,7 +122,7 @@ grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
"\n"
"namespace grpc {\n"
"class CompletionQueue;\n"
- "class ChannelInterface;\n"
+ "class Channel;\n"
"class RpcService;\n"
"class ServerCompletionQueue;\n"
"class ServerContext;\n"
@@ -554,17 +553,17 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
printer->Outdent();
printer->Print("};\n");
printer->Print(
- "class Stub GRPC_FINAL : public StubInterface,"
- " public ::grpc::InternalStub {\n public:\n");
+ "class Stub GRPC_FINAL : public StubInterface"
+ " {\n public:\n");
printer->Indent();
- printer->Print(
- "Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);\n");
+ printer->Print("Stub(const std::shared_ptr< ::grpc::Channel>& channel);\n");
for (int i = 0; i < service->method_count(); ++i) {
PrintHeaderClientMethod(printer, service->method(i), vars, true);
}
printer->Outdent();
printer->Print("\n private:\n");
printer->Indent();
+ printer->Print("std::shared_ptr< ::grpc::Channel> channel_;\n");
for (int i = 0; i < service->method_count(); ++i) {
PrintHeaderClientMethod(printer, service->method(i), vars, false);
}
@@ -575,7 +574,7 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
printer->Print("};\n");
printer->Print(
"static std::unique_ptr<Stub> NewStub(const std::shared_ptr< "
- "::grpc::ChannelInterface>& channel, "
+ "::grpc::Channel>& channel, "
"const ::grpc::StubOptions& options = ::grpc::StubOptions());\n");
printer->Print("\n");
@@ -703,7 +702,7 @@ grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
std::map<grpc::string, grpc::string> vars;
printer.Print(vars, "#include <grpc++/async_unary_call.h>\n");
- printer.Print(vars, "#include <grpc++/channel_interface.h>\n");
+ printer.Print(vars, "#include <grpc++/channel.h>\n");
printer.Print(vars, "#include <grpc++/impl/client_unary_call.h>\n");
printer.Print(vars, "#include <grpc++/impl/rpc_service_method.h>\n");
printer.Print(vars, "#include <grpc++/impl/service_type.h>\n");
@@ -738,7 +737,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::ClientContext* context, "
"const $Request$& request, $Response$* response) {\n");
printer->Print(*vars,
- " return ::grpc::BlockingUnaryCall(channel(), "
+ " return ::grpc::BlockingUnaryCall(channel_.get(), "
"rpcmethod_$Method$_, "
"context, request, response);\n"
"}\n\n");
@@ -751,7 +750,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
printer->Print(*vars,
" return new "
"::grpc::ClientAsyncResponseReader< $Response$>("
- "channel(), cq, "
+ "channel_.get(), cq, "
"rpcmethod_$Method$_, "
"context, request);\n"
"}\n\n");
@@ -762,7 +761,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::ClientContext* context, $Response$* response) {\n");
printer->Print(*vars,
" return new ::grpc::ClientWriter< $Request$>("
- "channel(), "
+ "channel_.get(), "
"rpcmethod_$Method$_, "
"context, response);\n"
"}\n\n");
@@ -773,7 +772,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::CompletionQueue* cq, void* tag) {\n");
printer->Print(*vars,
" return new ::grpc::ClientAsyncWriter< $Request$>("
- "channel(), cq, "
+ "channel_.get(), cq, "
"rpcmethod_$Method$_, "
"context, response, tag);\n"
"}\n\n");
@@ -785,7 +784,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::ClientContext* context, const $Request$& request) {\n");
printer->Print(*vars,
" return new ::grpc::ClientReader< $Response$>("
- "channel(), "
+ "channel_.get(), "
"rpcmethod_$Method$_, "
"context, request);\n"
"}\n\n");
@@ -796,7 +795,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::CompletionQueue* cq, void* tag) {\n");
printer->Print(*vars,
" return new ::grpc::ClientAsyncReader< $Response$>("
- "channel(), cq, "
+ "channel_.get(), cq, "
"rpcmethod_$Method$_, "
"context, request, tag);\n"
"}\n\n");
@@ -808,7 +807,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
printer->Print(*vars,
" return new ::grpc::ClientReaderWriter< "
"$Request$, $Response$>("
- "channel(), "
+ "channel_.get(), "
"rpcmethod_$Method$_, "
"context);\n"
"}\n\n");
@@ -820,7 +819,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
printer->Print(*vars,
" return new "
"::grpc::ClientAsyncReaderWriter< $Request$, $Response$>("
- "channel(), cq, "
+ "channel_.get(), cq, "
"rpcmethod_$Method$_, "
"context, tag);\n"
"}\n\n");
@@ -964,20 +963,19 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
}
printer->Print(*vars, "};\n\n");
- printer->Print(
- *vars,
- "std::unique_ptr< $ns$$Service$::Stub> $ns$$Service$::NewStub("
- "const std::shared_ptr< ::grpc::ChannelInterface>& channel, "
- "const ::grpc::StubOptions& options) {\n"
- " std::unique_ptr< $ns$$Service$::Stub> stub(new "
- "$ns$$Service$::Stub(channel));\n"
- " return stub;\n"
- "}\n\n");
+ printer->Print(*vars,
+ "std::unique_ptr< $ns$$Service$::Stub> $ns$$Service$::NewStub("
+ "const std::shared_ptr< ::grpc::Channel>& channel, "
+ "const ::grpc::StubOptions& options) {\n"
+ " std::unique_ptr< $ns$$Service$::Stub> stub(new "
+ "$ns$$Service$::Stub(channel));\n"
+ " return stub;\n"
+ "}\n\n");
printer->Print(*vars,
"$ns$$Service$::Stub::Stub(const std::shared_ptr< "
- "::grpc::ChannelInterface>& channel)\n");
+ "::grpc::Channel>& channel)\n");
printer->Indent();
- printer->Print(": ::grpc::InternalStub(channel)");
+ printer->Print(": channel_(channel)");
for (int i = 0; i < service->method_count(); ++i) {
const grpc::protobuf::MethodDescriptor *method = service->method(i);
(*vars)["Method"] = method->name();
@@ -991,13 +989,12 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
} else {
(*vars)["StreamingType"] = "BIDI_STREAMING";
}
- printer->Print(
- *vars,
- ", rpcmethod_$Method$_("
- "$prefix$$Service$_method_names[$Idx$], "
- "::grpc::RpcMethod::$StreamingType$, "
- "channel->RegisterMethod($prefix$$Service$_method_names[$Idx$])"
- ")\n");
+ printer->Print(*vars,
+ ", rpcmethod_$Method$_("
+ "$prefix$$Service$_method_names[$Idx$], "
+ "::grpc::RpcMethod::$StreamingType$, "
+ "channel"
+ ")\n");
}
printer->Print("{}\n\n");
printer->Outdent();
diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc
index 17f31c22cb..bb4be07beb 100644
--- a/src/cpp/client/channel.cc
+++ b/src/cpp/client/channel.cc
@@ -31,7 +31,7 @@
*
*/
-#include "src/cpp/client/channel.h"
+#include <grpc++/channel.h>
#include <memory>
@@ -52,8 +52,6 @@
namespace grpc {
-Channel::Channel(grpc_channel* channel) : c_channel_(channel) {}
-
Channel::Channel(const grpc::string& host, grpc_channel* channel)
: host_(host), c_channel_(channel) {}
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index b8caa1eae4..a3906fc781 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -71,7 +71,7 @@ void ClientContext::AddMetadata(const grpc::string& meta_key,
}
void ClientContext::set_call(grpc_call* call,
- const std::shared_ptr<ChannelInterface>& channel) {
+ const std::shared_ptr<Channel>& channel) {
GPR_ASSERT(call_ == nullptr);
call_ = call;
channel_ = channel;
diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc
index 5ae772f096..70ea7e0e27 100644
--- a/src/cpp/client/create_channel.cc
+++ b/src/cpp/client/create_channel.cc
@@ -34,15 +34,16 @@
#include <memory>
#include <sstream>
-#include "src/cpp/client/channel.h"
-#include <grpc++/channel_interface.h>
+#include <grpc++/channel.h>
#include <grpc++/channel_arguments.h>
#include <grpc++/create_channel.h>
+#include "src/cpp/client/create_channel_internal.h"
+
namespace grpc {
class ChannelArguments;
-std::shared_ptr<ChannelInterface> CreateChannel(
+std::shared_ptr<Channel> CreateChannel(
const grpc::string& target, const std::shared_ptr<Credentials>& creds,
const ChannelArguments& args) {
ChannelArguments cp_args = args;
@@ -50,10 +51,10 @@ std::shared_ptr<ChannelInterface> CreateChannel(
user_agent_prefix << "grpc-c++/" << grpc_version_string();
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(grpc_lame_client_channel_create(
- NULL, GRPC_STATUS_INVALID_ARGUMENT,
- "Invalid credentials.")));
+ return creds
+ ? creds->CreateChannel(target, cp_args)
+ : CreateChannelInternal("", grpc_lame_client_channel_create(
+ NULL, GRPC_STATUS_INVALID_ARGUMENT,
+ "Invalid credentials."));
}
} // namespace grpc
diff --git a/src/cpp/client/internal_stub.cc b/src/cpp/client/create_channel_internal.cc
index 91724a4837..9c5ab038cf 100644
--- a/src/cpp/client/internal_stub.cc
+++ b/src/cpp/client/create_channel_internal.cc
@@ -31,6 +31,16 @@
*
*/
-#include <grpc++/impl/internal_stub.h>
+#include <memory>
-namespace grpc {} // namespace grpc
+#include <grpc++/channel.h>
+
+struct grpc_channel;
+
+namespace grpc {
+
+std::shared_ptr<Channel> CreateChannelInternal(const grpc::string& host,
+ grpc_channel* c_channel) {
+ return std::shared_ptr<Channel>(new Channel(host, c_channel));
+}
+} // namespace grpc
diff --git a/src/cpp/client/channel.h b/src/cpp/client/create_channel_internal.h
index 7e406ad788..1692471990 100644
--- a/src/cpp/client/channel.h
+++ b/src/cpp/client/create_channel_internal.h
@@ -31,50 +31,21 @@
*
*/
-#ifndef GRPC_INTERNAL_CPP_CLIENT_CHANNEL_H
-#define GRPC_INTERNAL_CPP_CLIENT_CHANNEL_H
+#ifndef GRPC_INTERNAL_CPP_CLIENT_CREATE_CHANNEL_INTERNAL_H
+#define GRPC_INTERNAL_CPP_CLIENT_CREATE_CHANNEL_INTERNAL_H
#include <memory>
-#include <grpc++/channel_interface.h>
#include <grpc++/config.h>
-#include <grpc++/impl/grpc_library.h>
struct grpc_channel;
namespace grpc {
-class Call;
-class CallOpSetInterface;
-class ChannelArguments;
-class CompletionQueue;
-class Credentials;
-class StreamContextInterface;
+class Channel;
-class Channel GRPC_FINAL : public GrpcLibrary, public ChannelInterface {
- public:
- explicit Channel(grpc_channel* c_channel);
- Channel(const grpc::string& host, grpc_channel* c_channel);
- ~Channel() GRPC_OVERRIDE;
-
- void* RegisterMethod(const char* method) GRPC_OVERRIDE;
- Call CreateCall(const RpcMethod& method, ClientContext* context,
- CompletionQueue* cq) GRPC_OVERRIDE;
- void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) GRPC_OVERRIDE;
-
- grpc_connectivity_state GetState(bool try_to_connect) GRPC_OVERRIDE;
-
- private:
- void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
- gpr_timespec deadline, CompletionQueue* cq,
- void* tag) GRPC_OVERRIDE;
-
- bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
- gpr_timespec deadline) GRPC_OVERRIDE;
-
- const grpc::string host_;
- grpc_channel* const c_channel_; // owned
-};
+std::shared_ptr<Channel> CreateChannelInternal(const grpc::string& host,
+ grpc_channel* c_channel);
} // namespace grpc
-#endif // GRPC_INTERNAL_CPP_CLIENT_CHANNEL_H
+#endif // GRPC_INTERNAL_CPP_CLIENT_CREATE_CHANNEL_INTERNAL_H
diff --git a/src/cpp/client/generic_stub.cc b/src/cpp/client/generic_stub.cc
index 0c90578ae5..ee89c02965 100644
--- a/src/cpp/client/generic_stub.cc
+++ b/src/cpp/client/generic_stub.cc
@@ -44,8 +44,7 @@ std::unique_ptr<GenericClientAsyncReaderWriter> GenericStub::Call(
return std::unique_ptr<GenericClientAsyncReaderWriter>(
new GenericClientAsyncReaderWriter(
channel_.get(), cq,
- RpcMethod(method.c_str(), RpcMethod::BIDI_STREAMING, nullptr),
- context, tag));
+ RpcMethod(method.c_str(), RpcMethod::BIDI_STREAMING), context, tag));
}
} // namespace grpc
diff --git a/src/cpp/client/insecure_credentials.cc b/src/cpp/client/insecure_credentials.cc
index 2f9357b568..97931406af 100644
--- a/src/cpp/client/insecure_credentials.cc
+++ b/src/cpp/client/insecure_credentials.cc
@@ -34,22 +34,24 @@
#include <grpc/grpc.h>
#include <grpc/support/log.h>
+#include <grpc++/channel.h>
#include <grpc++/channel_arguments.h>
#include <grpc++/config.h>
#include <grpc++/credentials.h>
-#include "src/cpp/client/channel.h"
+#include "src/cpp/client/create_channel_internal.h"
namespace grpc {
namespace {
class InsecureCredentialsImpl GRPC_FINAL : public Credentials {
public:
- std::shared_ptr<grpc::ChannelInterface> CreateChannel(
+ std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) GRPC_OVERRIDE {
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
- return std::shared_ptr<ChannelInterface>(new Channel(
- grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr)));
+ return CreateChannelInternal(
+ "",
+ grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr));
}
// 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 6cd6b77fcf..1e912c6beb 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -32,21 +32,21 @@
*/
#include <grpc/support/log.h>
-
+#include <grpc++/channel.h>
#include <grpc++/channel_arguments.h>
#include <grpc++/impl/grpc_library.h>
-#include "src/cpp/client/channel.h"
+#include "src/cpp/client/create_channel_internal.h"
#include "src/cpp/client/secure_credentials.h"
namespace grpc {
-std::shared_ptr<grpc::ChannelInterface> SecureCredentials::CreateChannel(
+std::shared_ptr<grpc::Channel> SecureCredentials::CreateChannel(
const string& target, const grpc::ChannelArguments& args) {
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
- return std::shared_ptr<ChannelInterface>(new Channel(
+ return CreateChannelInternal(
args.GetSslTargetNameOverride(),
- grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args)));
+ grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args));
}
bool SecureCredentials::ApplyToCall(grpc_call* call) {
diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h
index c2b8d43a15..974d83514d 100644
--- a/src/cpp/client/secure_credentials.h
+++ b/src/cpp/client/secure_credentials.h
@@ -48,7 +48,7 @@ class SecureCredentials GRPC_FINAL : public Credentials {
grpc_credentials* GetRawCreds() { return c_creds_; }
bool ApplyToCall(grpc_call* call) GRPC_OVERRIDE;
- std::shared_ptr<grpc::ChannelInterface> CreateChannel(
+ std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) GRPC_OVERRIDE;
SecureCredentials* AsSecureCredentials() GRPC_OVERRIDE { return this; }
diff --git a/src/cpp/common/call.cc b/src/cpp/common/call.cc
index 0a5c976e01..479f14d42b 100644
--- a/src/cpp/common/call.cc
+++ b/src/cpp/common/call.cc
@@ -36,7 +36,7 @@
#include <grpc/support/alloc.h>
#include <grpc++/byte_buffer.h>
#include <grpc++/client_context.h>
-#include <grpc++/channel_interface.h>
+#include <grpc++/channel.h>
#include "src/core/profiling/timers.h"