From 8c2be9f22807870585111d88f5168dd11da99ce1 Mon Sep 17 00:00:00 2001 From: yang-g <yangg@google.com> Date: Wed, 19 Aug 2015 16:28:09 -0700 Subject: [PATCH] Remove ChannelInterface and replace it with Channel --- BUILD | 6 +- Makefile | 4 +- build.json | 3 +- examples/pubsub/main.cc | 4 +- examples/pubsub/publisher.cc | 2 +- examples/pubsub/publisher.h | 4 +- examples/pubsub/publisher_test.cc | 6 +- examples/pubsub/subscriber.cc | 2 +- examples/pubsub/subscriber.h | 4 +- examples/pubsub/subscriber_test.cc | 4 +- include/grpc++/async_unary_call.h | 4 +- .../grpc++/{channel_interface.h => channel.h} | 89 ++++++++++++++----- include/grpc++/client_context.h | 10 +-- include/grpc++/completion_queue.h | 5 +- include/grpc++/create_channel.h | 3 +- include/grpc++/credentials.h | 6 +- include/grpc++/generic_stub.h | 5 +- include/grpc++/impl/client_unary_call.h | 4 +- include/grpc++/impl/internal_stub.h | 9 +- include/grpc++/stream.h | 14 +-- src/compiler/cpp_generator.cc | 28 +++--- src/cpp/client/channel.cc | 2 +- src/cpp/client/channel.h | 80 ----------------- src/cpp/client/client_context.cc | 2 +- src/cpp/client/create_channel.cc | 7 +- src/cpp/client/insecure_credentials.cc | 6 +- src/cpp/client/secure_credentials.cc | 6 +- src/cpp/client/secure_credentials.h | 2 +- src/cpp/common/call.cc | 2 +- test/cpp/end2end/async_end2end_test.cc | 6 +- test/cpp/end2end/client_crash_test.cc | 2 +- test/cpp/end2end/end2end_test.cc | 8 +- test/cpp/end2end/generic_end2end_test.cc | 4 +- test/cpp/end2end/mock_test.cc | 4 +- test/cpp/end2end/server_crash_test.cc | 2 +- test/cpp/end2end/server_crash_test_client.cc | 2 +- test/cpp/end2end/thread_stress_test.cc | 4 +- test/cpp/end2end/zookeeper_test.cc | 4 +- test/cpp/interop/client.cc | 2 +- test/cpp/interop/client_helper.cc | 4 +- test/cpp/interop/client_helper.h | 4 +- test/cpp/interop/interop_client.cc | 4 +- test/cpp/interop/interop_client.h | 8 +- test/cpp/interop/reconnect_interop_client.cc | 6 +- test/cpp/qps/client.h | 4 +- test/cpp/qps/perf_db_client.h | 4 +- test/cpp/util/cli_call.cc | 4 +- test/cpp/util/cli_call.h | 4 +- test/cpp/util/cli_call_test.cc | 4 +- test/cpp/util/create_test_channel.cc | 8 +- test/cpp/util/create_test_channel.h | 10 +-- test/cpp/util/grpc_cli.cc | 4 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 3 +- tools/run_tests/sources_and_headers.json | 12 +-- vsprojects/grpc++/grpc++.vcxproj | 3 +- vsprojects/grpc++/grpc++.vcxproj.filters | 7 +- .../grpc++_unsecure/grpc++_unsecure.vcxproj | 3 +- .../grpc++_unsecure.vcxproj.filters | 7 +- 59 files changed, 203 insertions(+), 263 deletions(-) rename include/grpc++/{channel_interface.h => channel.h} (52%) delete mode 100644 src/cpp/client/channel.h diff --git a/BUILD b/BUILD index 7eb59797d4..adcc4cb413 100644 --- a/BUILD +++ b/BUILD @@ -675,7 +675,6 @@ cc_library( "src/cpp/client/secure_credentials.h", "src/cpp/common/secure_auth_context.h", "src/cpp/server/secure_server_credentials.h", - "src/cpp/client/channel.h", "src/cpp/common/create_auth_context.h", "src/cpp/client/secure_channel_arguments.cc", "src/cpp/client/secure_credentials.cc", @@ -714,8 +713,8 @@ cc_library( "include/grpc++/async_unary_call.h", "include/grpc++/auth_context.h", "include/grpc++/byte_buffer.h", + "include/grpc++/channel.h", "include/grpc++/channel_arguments.h", - "include/grpc++/channel_interface.h", "include/grpc++/client_context.h", "include/grpc++/completion_queue.h", "include/grpc++/config.h", @@ -767,7 +766,6 @@ cc_library( cc_library( name = "grpc++_unsecure", srcs = [ - "src/cpp/client/channel.h", "src/cpp/common/create_auth_context.h", "src/cpp/common/insecure_create_auth_context.cc", "src/cpp/client/channel.cc", @@ -801,8 +799,8 @@ cc_library( "include/grpc++/async_unary_call.h", "include/grpc++/auth_context.h", "include/grpc++/byte_buffer.h", + "include/grpc++/channel.h", "include/grpc++/channel_arguments.h", - "include/grpc++/channel_interface.h", "include/grpc++/client_context.h", "include/grpc++/completion_queue.h", "include/grpc++/config.h", diff --git a/Makefile b/Makefile index f3944eccbb..dba1a0457e 100644 --- a/Makefile +++ b/Makefile @@ -4630,8 +4630,8 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/async_unary_call.h \ include/grpc++/auth_context.h \ include/grpc++/byte_buffer.h \ + include/grpc++/channel.h \ include/grpc++/channel_arguments.h \ - include/grpc++/channel_interface.h \ include/grpc++/client_context.h \ include/grpc++/completion_queue.h \ include/grpc++/config.h \ @@ -4873,8 +4873,8 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/async_unary_call.h \ include/grpc++/auth_context.h \ include/grpc++/byte_buffer.h \ + include/grpc++/channel.h \ include/grpc++/channel_arguments.h \ - include/grpc++/channel_interface.h \ include/grpc++/client_context.h \ include/grpc++/completion_queue.h \ include/grpc++/config.h \ diff --git a/build.json b/build.json index 85457dde86..553e98db4b 100644 --- a/build.json +++ b/build.json @@ -34,8 +34,8 @@ "include/grpc++/async_unary_call.h", "include/grpc++/auth_context.h", "include/grpc++/byte_buffer.h", + "include/grpc++/channel.h", "include/grpc++/channel_arguments.h", - "include/grpc++/channel_interface.h", "include/grpc++/client_context.h", "include/grpc++/completion_queue.h", "include/grpc++/config.h", @@ -73,7 +73,6 @@ "include/grpc++/time.h" ], "headers": [ - "src/cpp/client/channel.h", "src/cpp/common/create_auth_context.h" ], "src": [ diff --git a/examples/pubsub/main.cc b/examples/pubsub/main.cc index b1898f18d9..fcee3b316b 100644 --- a/examples/pubsub/main.cc +++ b/examples/pubsub/main.cc @@ -41,7 +41,7 @@ #include <grpc/support/log.h> #include <gflags/gflags.h> #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> #include <grpc++/status.h> @@ -72,7 +72,7 @@ int main(int argc, char** argv) { ss << FLAGS_server_host << ":" << FLAGS_server_port; std::shared_ptr<grpc::Credentials> creds = grpc::GoogleDefaultCredentials(); - std::shared_ptr<grpc::ChannelInterface> channel = + std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(ss.str(), creds, grpc::ChannelArguments()); grpc::examples::pubsub::Publisher publisher(channel); diff --git a/examples/pubsub/publisher.cc b/examples/pubsub/publisher.cc index 458050af73..fd38ca92ed 100644 --- a/examples/pubsub/publisher.cc +++ b/examples/pubsub/publisher.cc @@ -50,7 +50,7 @@ namespace grpc { namespace examples { namespace pubsub { -Publisher::Publisher(std::shared_ptr<ChannelInterface> channel) +Publisher::Publisher(std::shared_ptr<Channel> channel) : stub_(PublisherService::NewStub(channel)) {} void Publisher::Shutdown() { stub_.reset(); } diff --git a/examples/pubsub/publisher.h b/examples/pubsub/publisher.h index 33bcf98df4..b98e6973dc 100644 --- a/examples/pubsub/publisher.h +++ b/examples/pubsub/publisher.h @@ -34,7 +34,7 @@ #ifndef GRPC_EXAMPLES_PUBSUB_PUBLISHER_H #define GRPC_EXAMPLES_PUBSUB_PUBLISHER_H -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/status.h> #include "examples/pubsub/pubsub.grpc.pb.h" @@ -45,7 +45,7 @@ namespace pubsub { class Publisher { public: - Publisher(std::shared_ptr<ChannelInterface> channel); + Publisher(std::shared_ptr<Channel> channel); void Shutdown(); Status CreateTopic(const grpc::string& topic); diff --git a/examples/pubsub/publisher_test.cc b/examples/pubsub/publisher_test.cc index 6b9dcacc49..972b426e64 100644 --- a/examples/pubsub/publisher_test.cc +++ b/examples/pubsub/publisher_test.cc @@ -32,7 +32,7 @@ */ #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/server.h> @@ -46,7 +46,7 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -using grpc::ChannelInterface; +using grpc::Channel; namespace grpc { namespace testing { @@ -124,7 +124,7 @@ class PublisherTest : public ::testing::Test { std::unique_ptr<Server> server_; PublisherServiceImpl service_; - std::shared_ptr<ChannelInterface> channel_; + std::shared_ptr<Channel> channel_; std::unique_ptr<grpc::examples::pubsub::Publisher> publisher_; }; diff --git a/examples/pubsub/subscriber.cc b/examples/pubsub/subscriber.cc index d9e0292ba0..0818f501db 100644 --- a/examples/pubsub/subscriber.cc +++ b/examples/pubsub/subscriber.cc @@ -48,7 +48,7 @@ namespace grpc { namespace examples { namespace pubsub { -Subscriber::Subscriber(std::shared_ptr<ChannelInterface> channel) +Subscriber::Subscriber(std::shared_ptr<Channel> channel) : stub_(SubscriberService::NewStub(channel)) {} void Subscriber::Shutdown() { stub_.reset(); } diff --git a/examples/pubsub/subscriber.h b/examples/pubsub/subscriber.h index 40ab45471d..87c833102c 100644 --- a/examples/pubsub/subscriber.h +++ b/examples/pubsub/subscriber.h @@ -34,7 +34,7 @@ #ifndef GRPC_EXAMPLES_PUBSUB_SUBSCRIBER_H #define GRPC_EXAMPLES_PUBSUB_SUBSCRIBER_H -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/status.h> #include "examples/pubsub/pubsub.grpc.pb.h" @@ -45,7 +45,7 @@ namespace pubsub { class Subscriber { public: - Subscriber(std::shared_ptr<ChannelInterface> channel); + Subscriber(std::shared_ptr<Channel> channel); void Shutdown(); Status CreateSubscription(const grpc::string& topic, diff --git a/examples/pubsub/subscriber_test.cc b/examples/pubsub/subscriber_test.cc index b0e7fc034b..7974ca88c2 100644 --- a/examples/pubsub/subscriber_test.cc +++ b/examples/pubsub/subscriber_test.cc @@ -32,7 +32,7 @@ */ #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/server.h> @@ -122,7 +122,7 @@ class SubscriberTest : public ::testing::Test { std::unique_ptr<Server> server_; SubscriberServiceImpl service_; - std::shared_ptr<ChannelInterface> channel_; + std::shared_ptr<Channel> channel_; std::unique_ptr<grpc::examples::pubsub::Subscriber> subscriber_; }; diff --git a/include/grpc++/async_unary_call.h b/include/grpc++/async_unary_call.h index 3d22df4b33..4e1dd15f32 100644 --- a/include/grpc++/async_unary_call.h +++ b/include/grpc++/async_unary_call.h @@ -34,7 +34,7 @@ #ifndef GRPCXX_ASYNC_UNARY_CALL_H #define GRPCXX_ASYNC_UNARY_CALL_H -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/completion_queue.h> #include <grpc++/server_context.h> @@ -58,7 +58,7 @@ class ClientAsyncResponseReader GRPC_FINAL : public ClientAsyncResponseReaderInterface<R> { public: template <class W> - ClientAsyncResponseReader(ChannelInterface* channel, CompletionQueue* cq, + ClientAsyncResponseReader(Channel* channel, CompletionQueue* cq, const RpcMethod& method, ClientContext* context, const W& request) : context_(context), call_(channel->CreateCall(method, context, cq)) { diff --git a/include/grpc++/channel_interface.h b/include/grpc++/channel.h similarity index 52% rename from include/grpc++/channel_interface.h rename to include/grpc++/channel.h index 4176cded7b..a4cef1b4d9 100644 --- a/include/grpc++/channel_interface.h +++ b/include/grpc++/channel.h @@ -31,36 +31,51 @@ * */ -#ifndef GRPCXX_CHANNEL_INTERFACE_H -#define GRPCXX_CHANNEL_INTERFACE_H +#ifndef GRPCXX_CHANNEL_H +#define GRPCXX_CHANNEL_H #include <memory> #include <grpc/grpc.h> -#include <grpc++/status.h> +#include <grpc++/config.h> #include <grpc++/impl/call.h> +#include <grpc++/impl/grpc_library.h> -struct grpc_call; +struct grpc_channel; namespace grpc { -class Call; -class CallOpBuffer; -class ClientContext; +class CallOpSetInterface; +class ChannelArguments; class CompletionQueue; -class RpcMethod; +class Credentials; +class SecureCredentials; -class ChannelInterface : public CallHook, - public std::enable_shared_from_this<ChannelInterface> { - public: - virtual ~ChannelInterface() {} +template <class R> +class ClientReader; +template <class W> +class ClientWriter; +template <class R, class W> +class ClientReaderWriter; +template <class R> +class ClientAsyncReader; +template <class W> +class ClientAsyncWriter; +template <class R, class W> +class ClientAsyncReaderWriter; +template <class R> +class ClientAsyncResponseReader; - virtual void* RegisterMethod(const char* method_name) = 0; - virtual Call CreateCall(const RpcMethod& method, ClientContext* context, - CompletionQueue* cq) = 0; +class Channel GRPC_FINAL : public GrpcLibrary, + public CallHook, + public std::enable_shared_from_this<Channel> { + public: + explicit Channel(grpc_channel* c_channel); + Channel(const grpc::string& host, grpc_channel* c_channel); + ~Channel(); // Get the current channel state. If the channel is in IDLE and try_to_connect // is set to true, try to connect. - virtual grpc_connectivity_state GetState(bool try_to_connect) = 0; + grpc_connectivity_state GetState(bool try_to_connect); // Return the tag on cq when the channel state is changed or deadline expires. // GetState needs to called to get the current state. @@ -79,14 +94,44 @@ class ChannelInterface : public CallHook, return WaitForStateChangeImpl(last_observed, deadline_tp.raw_time()); } + // Used by Stub only in generated code. + void* RegisterMethod(const char* method); + private: - virtual void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline, - CompletionQueue* cq, void* tag) = 0; - virtual bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline) = 0; + template <class R> + friend class ::grpc::ClientReader; + template <class W> + friend class ::grpc::ClientWriter; + template <class R, class W> + friend class ::grpc::ClientReaderWriter; + template <class R> + friend class ::grpc::ClientAsyncReader; + template <class W> + friend class ::grpc::ClientAsyncWriter; + template <class R, class W> + friend class ::grpc::ClientAsyncReaderWriter; + template <class R> + friend class ::grpc::ClientAsyncResponseReader; + template <class InputMessage, class OutputMessage> + friend Status BlockingUnaryCall(Channel* channel, const RpcMethod& method, + ClientContext* context, + const InputMessage& request, + OutputMessage* result); + + Call CreateCall(const RpcMethod& method, ClientContext* context, + CompletionQueue* cq); + void PerformOpsOnCall(CallOpSetInterface* ops, Call* call); + + void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline, CompletionQueue* cq, + void* tag); + bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline); + + const grpc::string host_; + grpc_channel* const c_channel_; // owned }; } // namespace grpc -#endif // GRPCXX_CHANNEL_INTERFACE_H +#endif // GRPCXX_CHANNEL_H diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h index 8de2ba4877..55ed17506a 100644 --- a/include/grpc++/client_context.h +++ b/include/grpc++/client_context.h @@ -51,7 +51,7 @@ struct census_context; namespace grpc { -class ChannelInterface; +class Channel; class CompletionQueue; class Credentials; class RpcMethod; @@ -215,20 +215,18 @@ class ClientContext { template <class R> friend class ::grpc::ClientAsyncResponseReader; template <class InputMessage, class OutputMessage> - friend Status BlockingUnaryCall(ChannelInterface* channel, - const RpcMethod& method, + friend Status BlockingUnaryCall(Channel* channel, const RpcMethod& method, ClientContext* context, const InputMessage& request, OutputMessage* result); grpc_call* call() { return call_; } - void set_call(grpc_call* call, - const std::shared_ptr<ChannelInterface>& channel); + void set_call(grpc_call* call, const std::shared_ptr<Channel>& channel); grpc::string authority() { return authority_; } bool initial_metadata_received_; - std::shared_ptr<ChannelInterface> channel_; + std::shared_ptr<Channel> channel_; grpc_call* call_; gpr_timespec deadline_; grpc::string authority_; diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h index 2f30211145..061f4874fa 100644 --- a/include/grpc++/completion_queue.h +++ b/include/grpc++/completion_queue.h @@ -65,7 +65,7 @@ template <class ServiceType, class RequestType, class ResponseType> class BidiStreamingHandler; class UnknownMethodHandler; -class ChannelInterface; +class Channel; class ClientContext; class CompletionQueue; class RpcMethod; @@ -143,8 +143,7 @@ class CompletionQueue : public GrpcLibrary { friend class ::grpc::Server; friend class ::grpc::ServerContext; template <class InputMessage, class OutputMessage> - friend Status BlockingUnaryCall(ChannelInterface* channel, - const RpcMethod& method, + friend Status BlockingUnaryCall(Channel* channel, const RpcMethod& method, ClientContext* context, const InputMessage& request, OutputMessage* result); diff --git a/include/grpc++/create_channel.h b/include/grpc++/create_channel.h index 424a93a64c..fe34452128 100644 --- a/include/grpc++/create_channel.h +++ b/include/grpc++/create_channel.h @@ -41,10 +41,9 @@ namespace grpc { class ChannelArguments; -class ChannelInterface; // If creds does not hold an object or is invalid, a lame channel is returned. -std::shared_ptr<ChannelInterface> CreateChannel( +std::shared_ptr<Channel> CreateChannel( const grpc::string& target, const std::shared_ptr<Credentials>& creds, const ChannelArguments& args); diff --git a/include/grpc++/credentials.h b/include/grpc++/credentials.h index a4f1e73118..306dc961c0 100644 --- a/include/grpc++/credentials.h +++ b/include/grpc++/credentials.h @@ -41,7 +41,7 @@ namespace grpc { class ChannelArguments; -class ChannelInterface; +class Channel; class SecureCredentials; class Credentials : public GrpcLibrary { @@ -57,11 +57,11 @@ class Credentials : public GrpcLibrary { virtual SecureCredentials* AsSecureCredentials() = 0; private: - friend std::shared_ptr<ChannelInterface> CreateChannel( + friend std::shared_ptr<Channel> CreateChannel( const grpc::string& target, const std::shared_ptr<Credentials>& creds, const ChannelArguments& args); - virtual std::shared_ptr<ChannelInterface> CreateChannel( + virtual std::shared_ptr<Channel> CreateChannel( const grpc::string& target, const ChannelArguments& args) = 0; }; diff --git a/include/grpc++/generic_stub.h b/include/grpc++/generic_stub.h index 172f10e45a..734440881e 100644 --- a/include/grpc++/generic_stub.h +++ b/include/grpc++/generic_stub.h @@ -47,8 +47,7 @@ typedef ClientAsyncReaderWriter<ByteBuffer, ByteBuffer> // by name. class GenericStub GRPC_FINAL { public: - explicit GenericStub(std::shared_ptr<ChannelInterface> channel) - : channel_(channel) {} + explicit GenericStub(std::shared_ptr<Channel> channel) : channel_(channel) {} // begin a call to a named method std::unique_ptr<GenericClientAsyncReaderWriter> Call( @@ -56,7 +55,7 @@ class GenericStub GRPC_FINAL { void* tag); private: - std::shared_ptr<ChannelInterface> channel_; + std::shared_ptr<Channel> channel_; }; } // namespace grpc diff --git a/include/grpc++/impl/client_unary_call.h b/include/grpc++/impl/client_unary_call.h index b77ce7d02c..4aae816cd7 100644 --- a/include/grpc++/impl/client_unary_call.h +++ b/include/grpc++/impl/client_unary_call.h @@ -41,14 +41,14 @@ namespace grpc { -class ChannelInterface; +class Channel; class ClientContext; class CompletionQueue; class RpcMethod; // Wrapper that performs a blocking unary call template <class InputMessage, class OutputMessage> -Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, +Status BlockingUnaryCall(Channel* channel, const RpcMethod& method, ClientContext* context, const InputMessage& request, OutputMessage* result) { CompletionQueue cq; diff --git a/include/grpc++/impl/internal_stub.h b/include/grpc++/impl/internal_stub.h index 370a3b8ac5..60eb3fdd06 100644 --- a/include/grpc++/impl/internal_stub.h +++ b/include/grpc++/impl/internal_stub.h @@ -36,20 +36,19 @@ #include <memory> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> namespace grpc { class InternalStub { public: - InternalStub(const std::shared_ptr<ChannelInterface>& channel) - : channel_(channel) {} + InternalStub(const std::shared_ptr<Channel>& channel) : channel_(channel) {} virtual ~InternalStub() {} - ChannelInterface* channel() { return channel_.get(); } + Channel* channel() { return channel_.get(); } private: - const std::shared_ptr<ChannelInterface> channel_; + const std::shared_ptr<Channel> channel_; }; } // namespace grpc diff --git a/include/grpc++/stream.h b/include/grpc++/stream.h index 45dafcd282..577eb4e925 100644 --- a/include/grpc++/stream.h +++ b/include/grpc++/stream.h @@ -34,7 +34,7 @@ #ifndef GRPCXX_STREAM_H #define GRPCXX_STREAM_H -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/completion_queue.h> #include <grpc++/server_context.h> @@ -100,7 +100,7 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface<R> { public: // Blocking create a stream and write the first request out. template <class W> - ClientReader(ChannelInterface* channel, const RpcMethod& method, + ClientReader(Channel* channel, const RpcMethod& method, ClientContext* context, const W& request) : context_(context), call_(channel->CreateCall(method, context, &cq_)) { CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, @@ -163,7 +163,7 @@ class ClientWriter : public ClientWriterInterface<W> { public: // Blocking create a stream. template <class R> - ClientWriter(ChannelInterface* channel, const RpcMethod& method, + ClientWriter(Channel* channel, const RpcMethod& method, ClientContext* context, R* response) : context_(context), call_(channel->CreateCall(method, context, &cq_)) { finish_ops_.RecvMessage(response); @@ -221,7 +221,7 @@ template <class W, class R> class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> { public: // Blocking create a stream. - ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method, + ClientReaderWriter(Channel* channel, const RpcMethod& method, ClientContext* context) : context_(context), call_(channel->CreateCall(method, context, &cq_)) { CallOpSet<CallOpSendInitialMetadata> ops; @@ -425,7 +425,7 @@ class ClientAsyncReader GRPC_FINAL : public ClientAsyncReaderInterface<R> { public: // Create a stream and write the first request out. template <class W> - ClientAsyncReader(ChannelInterface* channel, CompletionQueue* cq, + ClientAsyncReader(Channel* channel, CompletionQueue* cq, const RpcMethod& method, ClientContext* context, const W& request, void* tag) : context_(context), call_(channel->CreateCall(method, context, cq)) { @@ -484,7 +484,7 @@ template <class W> class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface<W> { public: template <class R> - ClientAsyncWriter(ChannelInterface* channel, CompletionQueue* cq, + ClientAsyncWriter(Channel* channel, CompletionQueue* cq, const RpcMethod& method, ClientContext* context, R* response, void* tag) : context_(context), call_(channel->CreateCall(method, context, cq)) { @@ -549,7 +549,7 @@ template <class W, class R> class ClientAsyncReaderWriter GRPC_FINAL : public ClientAsyncReaderWriterInterface<W, R> { public: - ClientAsyncReaderWriter(ChannelInterface* channel, CompletionQueue* cq, + ClientAsyncReaderWriter(Channel* channel, CompletionQueue* cq, const RpcMethod& method, ClientContext* context, void* tag) : context_(context), call_(channel->CreateCall(method, context, cq)) { diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index ea487bcd89..731ba58fb1 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -123,7 +123,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" @@ -557,8 +557,7 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer, "class Stub GRPC_FINAL : public StubInterface," " public ::grpc::InternalStub {\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); } @@ -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"); @@ -964,18 +963,17 @@ 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)"); for (int i = 0; i < service->method_count(); ++i) { diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc index 9695a0f14b..d9ffdc30cd 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> diff --git a/src/cpp/client/channel.h b/src/cpp/client/channel.h deleted file mode 100644 index 7e406ad788..0000000000 --- a/src/cpp/client/channel.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_INTERNAL_CPP_CLIENT_CHANNEL_H -#define GRPC_INTERNAL_CPP_CLIENT_CHANNEL_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 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 -}; - -} // namespace grpc - -#endif // GRPC_INTERNAL_CPP_CLIENT_CHANNEL_H 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..704470693e 100644 --- a/src/cpp/client/create_channel.cc +++ b/src/cpp/client/create_channel.cc @@ -34,15 +34,14 @@ #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> 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; @@ -51,7 +50,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>( + : std::shared_ptr<Channel>( new Channel(grpc_lame_client_channel_create( NULL, GRPC_STATUS_INVALID_ARGUMENT, "Invalid credentials."))); diff --git a/src/cpp/client/insecure_credentials.cc b/src/cpp/client/insecure_credentials.cc index 2f9357b568..70ce17dc6d 100644 --- a/src/cpp/client/insecure_credentials.cc +++ b/src/cpp/client/insecure_credentials.cc @@ -34,21 +34,21 @@ #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" 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( + return std::shared_ptr<Channel>(new Channel( grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr))); } diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 6cd6b77fcf..b32f783fa3 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -33,18 +33,18 @@ #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/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 std::shared_ptr<Channel>(new Channel( args.GetSslTargetNameOverride(), grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args))); } 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" diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index a30c841216..7006ebb83a 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -39,7 +39,7 @@ #include "test/cpp/util/echo.grpc.pb.h" #include <grpc++/async_unary_call.h> #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> @@ -136,7 +136,7 @@ class AsyncEnd2endTest : public ::testing::Test { } void ResetStub() { - std::shared_ptr<ChannelInterface> channel = CreateChannel( + std::shared_ptr<Channel> channel = CreateChannel( server_address_.str(), InsecureCredentials(), ChannelArguments()); stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel)); } @@ -672,7 +672,7 @@ TEST_F(AsyncEnd2endTest, ServerCheckDone) { } TEST_F(AsyncEnd2endTest, UnimplementedRpc) { - std::shared_ptr<ChannelInterface> channel = CreateChannel( + std::shared_ptr<Channel> channel = CreateChannel( server_address_.str(), InsecureCredentials(), ChannelArguments()); std::unique_ptr<grpc::cpp::test::util::UnimplementedService::Stub> stub; stub = diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc index 1c2a5c3a36..89708a2ef6 100644 --- a/test/cpp/end2end/client_crash_test.cc +++ b/test/cpp/end2end/client_crash_test.cc @@ -36,7 +36,7 @@ #include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h" #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 350b10726f..fc4e88c2a7 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -41,7 +41,7 @@ #include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h" #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> @@ -106,7 +106,7 @@ bool CheckIsLocalhost(const grpc::string& addr) { class Proxy : public ::grpc::cpp::test::util::TestService::Service { public: - Proxy(std::shared_ptr<ChannelInterface> channel) + Proxy(std::shared_ptr<Channel> channel) : stub_(grpc::cpp::test::util::TestService::NewStub(channel)) {} Status Echo(ServerContext* server_context, const EchoRequest* request, @@ -319,7 +319,7 @@ class End2endTest : public ::testing::TestWithParam<bool> { stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel_)); } - std::shared_ptr<ChannelInterface> channel_; + std::shared_ptr<Channel> channel_; std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub_; std::unique_ptr<Server> server_; std::unique_ptr<Server> proxy_server_; @@ -571,7 +571,7 @@ TEST_F(End2endTest, DiffPackageServices) { TEST_F(End2endTest, BadCredentials) { std::shared_ptr<Credentials> bad_creds = ServiceAccountCredentials("", "", 1); EXPECT_EQ(static_cast<Credentials*>(nullptr), bad_creds.get()); - std::shared_ptr<ChannelInterface> channel = + std::shared_ptr<Channel> channel = CreateChannel(server_address_.str(), bad_creds, ChannelArguments()); std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub( grpc::cpp::test::util::TestService::NewStub(channel)); diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 3120cec938..b817198fa7 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -41,7 +41,7 @@ #include <grpc++/async_unary_call.h> #include <grpc++/byte_buffer.h> #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> @@ -127,7 +127,7 @@ class GenericEnd2endTest : public ::testing::Test { } void ResetStub() { - std::shared_ptr<ChannelInterface> channel = CreateChannel( + std::shared_ptr<Channel> channel = CreateChannel( server_address_.str(), InsecureCredentials(), ChannelArguments()); generic_stub_.reset(new GenericStub(channel)); } diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 32130e24e9..96b6ecbd6e 100644 --- a/test/cpp/end2end/mock_test.cc +++ b/test/cpp/end2end/mock_test.cc @@ -38,7 +38,7 @@ #include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h" #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> @@ -251,7 +251,7 @@ class MockTest : public ::testing::Test { void TearDown() GRPC_OVERRIDE { server_->Shutdown(); } void ResetStub() { - std::shared_ptr<ChannelInterface> channel = CreateChannel( + std::shared_ptr<Channel> channel = CreateChannel( server_address_.str(), InsecureCredentials(), ChannelArguments()); stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel)); } diff --git a/test/cpp/end2end/server_crash_test.cc b/test/cpp/end2end/server_crash_test.cc index 5c7bb4e653..2688f2c4ea 100644 --- a/test/cpp/end2end/server_crash_test.cc +++ b/test/cpp/end2end/server_crash_test.cc @@ -36,7 +36,7 @@ #include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h" #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> diff --git a/test/cpp/end2end/server_crash_test_client.cc b/test/cpp/end2end/server_crash_test_client.cc index 1da4f05c8d..52dce8f28e 100644 --- a/test/cpp/end2end/server_crash_test_client.cc +++ b/test/cpp/end2end/server_crash_test_client.cc @@ -38,7 +38,7 @@ #include <gflags/gflags.h> #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index ff9c945c7c..e59a77dc9e 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -39,7 +39,7 @@ #include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h" #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> @@ -197,7 +197,7 @@ class End2endTest : public ::testing::Test { void TearDown() GRPC_OVERRIDE { server_->Shutdown(); } void ResetStub() { - std::shared_ptr<ChannelInterface> channel = CreateChannel( + std::shared_ptr<Channel> channel = CreateChannel( server_address_.str(), InsecureCredentials(), ChannelArguments()); stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel)); } diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc index f5eba66cb2..d7fac3d07e 100644 --- a/test/cpp/end2end/zookeeper_test.cc +++ b/test/cpp/end2end/zookeeper_test.cc @@ -36,7 +36,7 @@ #include "test/cpp/util/echo.grpc.pb.h" #include "src/core/support/env.h" #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> @@ -170,7 +170,7 @@ class ZookeeperTest : public ::testing::Test { return strs.str(); } - std::shared_ptr<ChannelInterface> channel_; + std::shared_ptr<Channel> channel_; std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub_; std::unique_ptr<Server> server1_; std::unique_ptr<Server> server2_; diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 48143b2e53..d9e4f1ba6a 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -38,7 +38,7 @@ #include <grpc/grpc.h> #include <grpc/support/log.h> #include <gflags/gflags.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/status.h> #include <grpc++/stream.h> diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index b8a222c54a..91c8dbc0c3 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -44,7 +44,7 @@ #include <grpc/support/log.h> #include <gflags/gflags.h> #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> #include <grpc++/stream.h> @@ -103,7 +103,7 @@ grpc::string GetOauth2AccessToken() { return access_token; } -std::shared_ptr<ChannelInterface> CreateChannelForTestCase( +std::shared_ptr<Channel> CreateChannelForTestCase( const grpc::string& test_case) { GPR_ASSERT(FLAGS_server_port); const int host_port_buf_size = 1024; diff --git a/test/cpp/interop/client_helper.h b/test/cpp/interop/client_helper.h index 000374ae8e..3b46d87016 100644 --- a/test/cpp/interop/client_helper.h +++ b/test/cpp/interop/client_helper.h @@ -37,7 +37,7 @@ #include <memory> #include <grpc++/config.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> namespace grpc { namespace testing { @@ -46,7 +46,7 @@ grpc::string GetServiceAccountJsonKey(); grpc::string GetOauth2AccessToken(); -std::shared_ptr<ChannelInterface> CreateChannelForTestCase( +std::shared_ptr<Channel> CreateChannelForTestCase( const grpc::string& test_case); class InteropClientContextInspector { diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 5ed14d556a..c73505c670 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -42,7 +42,7 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/useful.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/credentials.h> #include <grpc++/status.h> @@ -84,7 +84,7 @@ CompressionType GetInteropCompressionTypeFromCompressionAlgorithm( } } // namespace -InteropClient::InteropClient(std::shared_ptr<ChannelInterface> channel) +InteropClient::InteropClient(std::shared_ptr<Channel> channel) : channel_(channel) {} void InteropClient::AssertOkOrPrintErrorStatus(const Status& s) { diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index d6fb9bff39..354c2c6195 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -36,7 +36,7 @@ #include <memory> #include <grpc/grpc.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/status.h> #include "test/proto/messages.grpc.pb.h" @@ -45,10 +45,10 @@ namespace testing { class InteropClient { public: - explicit InteropClient(std::shared_ptr<ChannelInterface> channel); + explicit InteropClient(std::shared_ptr<Channel> channel); ~InteropClient() {} - void Reset(std::shared_ptr<ChannelInterface> channel) { channel_ = channel; } + void Reset(std::shared_ptr<Channel> channel) { channel_ = channel; } void DoEmpty(); void DoLargeUnary(); @@ -82,7 +82,7 @@ class InteropClient { void PerformLargeUnary(SimpleRequest* request, SimpleResponse* response); void AssertOkOrPrintErrorStatus(const Status& s); - std::shared_ptr<ChannelInterface> channel_; + std::shared_ptr<Channel> channel_; }; } // namespace testing diff --git a/test/cpp/interop/reconnect_interop_client.cc b/test/cpp/interop/reconnect_interop_client.cc index 65f098050e..675c6ff073 100644 --- a/test/cpp/interop/reconnect_interop_client.cc +++ b/test/cpp/interop/reconnect_interop_client.cc @@ -37,7 +37,7 @@ #include <grpc/grpc.h> #include <grpc/support/log.h> #include <gflags/gflags.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/status.h> #include "test/cpp/util/create_test_channel.h" @@ -50,7 +50,7 @@ DEFINE_int32(server_control_port, 0, "Server port for control rpcs."); DEFINE_int32(server_retry_port, 0, "Server port for testing reconnection."); DEFINE_string(server_host, "127.0.0.1", "Server host to connect to"); -using grpc::ChannelInterface; +using grpc::Channel; using grpc::ClientContext; using grpc::CreateTestChannel; using grpc::Status; @@ -78,7 +78,7 @@ int main(int argc, char** argv) { gpr_log(GPR_INFO, "Starting connections with retries."); server_address.str(""); server_address << FLAGS_server_host << ':' << FLAGS_server_retry_port; - std::shared_ptr<ChannelInterface> retry_channel = + std::shared_ptr<Channel> retry_channel = CreateTestChannel(server_address.str(), true); // About 13 retries. const int kDeadlineSeconds = 540; diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 1c4f46328f..5395d02e32 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -125,11 +125,11 @@ class Client { channel_ = CreateTestChannel(target, config.enable_ssl()); stub_ = TestService::NewStub(channel_); } - ChannelInterface* get_channel() { return channel_.get(); } + Channel* get_channel() { return channel_.get(); } TestService::Stub* get_stub() { return stub_.get(); } private: - std::shared_ptr<ChannelInterface> channel_; + std::shared_ptr<Channel> channel_; std::unique_ptr<TestService::Stub> stub_; }; std::vector<ClientChannelInfo> channels_; diff --git a/test/cpp/qps/perf_db_client.h b/test/cpp/qps/perf_db_client.h index 7a9d86d3a6..3433cd88d1 100644 --- a/test/cpp/qps/perf_db_client.h +++ b/test/cpp/qps/perf_db_client.h @@ -38,7 +38,7 @@ #include <grpc/grpc.h> #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> @@ -65,7 +65,7 @@ class PerfDbClient { client_user_time_ = DBL_MIN; } - void init(std::shared_ptr<ChannelInterface> channel) { + void init(std::shared_ptr<Channel> channel) { stub_ = PerfDbTransfer::NewStub(channel); } diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index ac88910a01..d0a300f511 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -36,7 +36,7 @@ #include <iostream> #include <grpc++/byte_buffer.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/generic_stub.h> #include <grpc++/status.h> @@ -52,7 +52,7 @@ namespace { void* tag(int i) { return (void*)(gpr_intptr)i; } } // namespace -Status CliCall::Call(std::shared_ptr<grpc::ChannelInterface> channel, +Status CliCall::Call(std::shared_ptr<grpc::Channel> channel, const grpc::string& method, const grpc::string& request, grpc::string* response, const MetadataContainer& metadata, MetadataContainer* server_initial_metadata, diff --git a/test/cpp/util/cli_call.h b/test/cpp/util/cli_call.h index 8d114c9cb5..46b5dd3e4f 100644 --- a/test/cpp/util/cli_call.h +++ b/test/cpp/util/cli_call.h @@ -36,7 +36,7 @@ #include <map> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/config.h> #include <grpc++/status.h> @@ -46,7 +46,7 @@ namespace testing { class CliCall GRPC_FINAL { public: typedef std::multimap<grpc::string, grpc::string> MetadataContainer; - static Status Call(std::shared_ptr<grpc::ChannelInterface> channel, + static Status Call(std::shared_ptr<grpc::Channel> channel, const grpc::string& method, const grpc::string& request, grpc::string* response, const MetadataContainer& metadata, MetadataContainer* server_initial_metadata, diff --git a/test/cpp/util/cli_call_test.cc b/test/cpp/util/cli_call_test.cc index 848a3aee57..146e96720f 100644 --- a/test/cpp/util/cli_call_test.cc +++ b/test/cpp/util/cli_call_test.cc @@ -35,7 +35,7 @@ #include "test/cpp/util/cli_call.h" #include "test/cpp/util/echo.grpc.pb.h" #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> @@ -97,7 +97,7 @@ class CliCallTest : public ::testing::Test { stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel_)); } - std::shared_ptr<ChannelInterface> channel_; + std::shared_ptr<Channel> channel_; std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub_; std::unique_ptr<Server> server_; std::ostringstream server_address_; diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index dc48fa2d87..43e719ef6b 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -55,7 +55,7 @@ namespace grpc { // CreateTestChannel("test.google.com:443", "", true, true, creds); // same as above // CreateTestChannel("", "test.google.com:443", true, true, creds); -std::shared_ptr<ChannelInterface> CreateTestChannel( +std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots, const std::shared_ptr<Credentials>& creds) { @@ -80,7 +80,7 @@ std::shared_ptr<ChannelInterface> CreateTestChannel( } } -std::shared_ptr<ChannelInterface> CreateTestChannel( +std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots) { return CreateTestChannel(server, override_hostname, enable_ssl, @@ -88,8 +88,8 @@ std::shared_ptr<ChannelInterface> CreateTestChannel( } // Shortcut for end2end and interop tests. -std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server, - bool enable_ssl) { +std::shared_ptr<Channel> CreateTestChannel(const grpc::string& server, + bool enable_ssl) { return CreateTestChannel(server, "foo.test.google.fr", enable_ssl, false); } diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index 5f2609ddd8..129cc746f9 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -40,16 +40,16 @@ #include <grpc++/credentials.h> namespace grpc { -class ChannelInterface; +class Channel; -std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server, - bool enable_ssl); +std::shared_ptr<Channel> CreateTestChannel(const grpc::string& server, + bool enable_ssl); -std::shared_ptr<ChannelInterface> CreateTestChannel( +std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots); -std::shared_ptr<ChannelInterface> CreateTestChannel( +std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots, const std::shared_ptr<Credentials>& creds); diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc index 3c3baeb769..15c56a352c 100644 --- a/test/cpp/util/grpc_cli.cc +++ b/test/cpp/util/grpc_cli.cc @@ -67,7 +67,7 @@ #include "test/cpp/util/cli_call.h" #include "test/cpp/util/test_config.h" #include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc++/channel.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> @@ -154,7 +154,7 @@ int main(int argc, char** argv) { creds = grpc::SslCredentials(grpc::SslCredentialsOptions()); } } - std::shared_ptr<grpc::ChannelInterface> channel = + std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(server_address, creds, grpc::ChannelArguments()); grpc::string response; diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 790e637b72..366fc9962c 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -764,8 +764,8 @@ INPUT = include/grpc++/async_generic_service.h \ include/grpc++/async_unary_call.h \ include/grpc++/auth_context.h \ include/grpc++/byte_buffer.h \ +include/grpc++/channel.h \ include/grpc++/channel_arguments.h \ -include/grpc++/channel_interface.h \ include/grpc++/client_context.h \ include/grpc++/completion_queue.h \ include/grpc++/config.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index cd1279e2a6..7137018910 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -764,8 +764,8 @@ INPUT = include/grpc++/async_generic_service.h \ include/grpc++/async_unary_call.h \ include/grpc++/auth_context.h \ include/grpc++/byte_buffer.h \ +include/grpc++/channel.h \ include/grpc++/channel_arguments.h \ -include/grpc++/channel_interface.h \ include/grpc++/client_context.h \ include/grpc++/completion_queue.h \ include/grpc++/config.h \ @@ -804,7 +804,6 @@ include/grpc++/time.h \ src/cpp/client/secure_credentials.h \ src/cpp/common/secure_auth_context.h \ src/cpp/server/secure_server_credentials.h \ -src/cpp/client/channel.h \ src/cpp/common/create_auth_context.h \ src/cpp/client/secure_channel_arguments.cc \ src/cpp/client/secure_credentials.cc \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 72e6c41508..20eeabd288 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -13105,8 +13105,8 @@ "include/grpc++/async_unary_call.h", "include/grpc++/auth_context.h", "include/grpc++/byte_buffer.h", + "include/grpc++/channel.h", "include/grpc++/channel_arguments.h", - "include/grpc++/channel_interface.h", "include/grpc++/client_context.h", "include/grpc++/completion_queue.h", "include/grpc++/config.h", @@ -13142,7 +13142,6 @@ "include/grpc++/stub_options.h", "include/grpc++/thread_pool_interface.h", "include/grpc++/time.h", - "src/cpp/client/channel.h", "src/cpp/client/secure_credentials.h", "src/cpp/common/create_auth_context.h", "src/cpp/common/secure_auth_context.h", @@ -13155,8 +13154,8 @@ "include/grpc++/async_unary_call.h", "include/grpc++/auth_context.h", "include/grpc++/byte_buffer.h", + "include/grpc++/channel.h", "include/grpc++/channel_arguments.h", - "include/grpc++/channel_interface.h", "include/grpc++/client_context.h", "include/grpc++/completion_queue.h", "include/grpc++/config.h", @@ -13193,7 +13192,6 @@ "include/grpc++/thread_pool_interface.h", "include/grpc++/time.h", "src/cpp/client/channel.cc", - "src/cpp/client/channel.h", "src/cpp/client/channel_arguments.cc", "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", @@ -13279,8 +13277,8 @@ "include/grpc++/async_unary_call.h", "include/grpc++/auth_context.h", "include/grpc++/byte_buffer.h", + "include/grpc++/channel.h", "include/grpc++/channel_arguments.h", - "include/grpc++/channel_interface.h", "include/grpc++/client_context.h", "include/grpc++/completion_queue.h", "include/grpc++/config.h", @@ -13316,7 +13314,6 @@ "include/grpc++/stub_options.h", "include/grpc++/thread_pool_interface.h", "include/grpc++/time.h", - "src/cpp/client/channel.h", "src/cpp/common/create_auth_context.h" ], "language": "c++", @@ -13326,8 +13323,8 @@ "include/grpc++/async_unary_call.h", "include/grpc++/auth_context.h", "include/grpc++/byte_buffer.h", + "include/grpc++/channel.h", "include/grpc++/channel_arguments.h", - "include/grpc++/channel_interface.h", "include/grpc++/client_context.h", "include/grpc++/completion_queue.h", "include/grpc++/config.h", @@ -13364,7 +13361,6 @@ "include/grpc++/thread_pool_interface.h", "include/grpc++/time.h", "src/cpp/client/channel.cc", - "src/cpp/client/channel.h", "src/cpp/client/channel_arguments.cc", "src/cpp/client/client_context.cc", "src/cpp/client/create_channel.cc", diff --git a/vsprojects/grpc++/grpc++.vcxproj b/vsprojects/grpc++/grpc++.vcxproj index 929bc1500e..8ce96cc0e2 100644 --- a/vsprojects/grpc++/grpc++.vcxproj +++ b/vsprojects/grpc++/grpc++.vcxproj @@ -217,8 +217,8 @@ <ClInclude Include="..\..\include\grpc++\async_unary_call.h" /> <ClInclude Include="..\..\include\grpc++\auth_context.h" /> <ClInclude Include="..\..\include\grpc++\byte_buffer.h" /> + <ClInclude Include="..\..\include\grpc++\channel.h" /> <ClInclude Include="..\..\include\grpc++\channel_arguments.h" /> - <ClInclude Include="..\..\include\grpc++\channel_interface.h" /> <ClInclude Include="..\..\include\grpc++\client_context.h" /> <ClInclude Include="..\..\include\grpc++\completion_queue.h" /> <ClInclude Include="..\..\include\grpc++\config.h" /> @@ -259,7 +259,6 @@ <ClInclude Include="..\..\src\cpp\client\secure_credentials.h" /> <ClInclude Include="..\..\src\cpp\common\secure_auth_context.h" /> <ClInclude Include="..\..\src\cpp\server\secure_server_credentials.h" /> - <ClInclude Include="..\..\src\cpp\client\channel.h" /> <ClInclude Include="..\..\src\cpp\common\create_auth_context.h" /> </ItemGroup> <ItemGroup> diff --git a/vsprojects/grpc++/grpc++.vcxproj.filters b/vsprojects/grpc++/grpc++.vcxproj.filters index 0408fb46a5..924cbc4c73 100644 --- a/vsprojects/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/grpc++/grpc++.vcxproj.filters @@ -108,10 +108,10 @@ <ClInclude Include="..\..\include\grpc++\byte_buffer.h"> <Filter>include\grpc++</Filter> </ClInclude> - <ClInclude Include="..\..\include\grpc++\channel_arguments.h"> + <ClInclude Include="..\..\include\grpc++\channel.h"> <Filter>include\grpc++</Filter> </ClInclude> - <ClInclude Include="..\..\include\grpc++\channel_interface.h"> + <ClInclude Include="..\..\include\grpc++\channel_arguments.h"> <Filter>include\grpc++</Filter> </ClInclude> <ClInclude Include="..\..\include\grpc++\client_context.h"> @@ -230,9 +230,6 @@ <ClInclude Include="..\..\src\cpp\server\secure_server_credentials.h"> <Filter>src\cpp\server</Filter> </ClInclude> - <ClInclude Include="..\..\src\cpp\client\channel.h"> - <Filter>src\cpp\client</Filter> - </ClInclude> <ClInclude Include="..\..\src\cpp\common\create_auth_context.h"> <Filter>src\cpp\common</Filter> </ClInclude> diff --git a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj index 2ff252e04e..00667d38d7 100644 --- a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -217,8 +217,8 @@ <ClInclude Include="..\..\include\grpc++\async_unary_call.h" /> <ClInclude Include="..\..\include\grpc++\auth_context.h" /> <ClInclude Include="..\..\include\grpc++\byte_buffer.h" /> + <ClInclude Include="..\..\include\grpc++\channel.h" /> <ClInclude Include="..\..\include\grpc++\channel_arguments.h" /> - <ClInclude Include="..\..\include\grpc++\channel_interface.h" /> <ClInclude Include="..\..\include\grpc++\client_context.h" /> <ClInclude Include="..\..\include\grpc++\completion_queue.h" /> <ClInclude Include="..\..\include\grpc++\config.h" /> @@ -256,7 +256,6 @@ <ClInclude Include="..\..\include\grpc++\time.h" /> </ItemGroup> <ItemGroup> - <ClInclude Include="..\..\src\cpp\client\channel.h" /> <ClInclude Include="..\..\src\cpp\common\create_auth_context.h" /> </ItemGroup> <ItemGroup> diff --git a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index b4fae7741c..12d42f5e61 100644 --- a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -93,10 +93,10 @@ <ClInclude Include="..\..\include\grpc++\byte_buffer.h"> <Filter>include\grpc++</Filter> </ClInclude> - <ClInclude Include="..\..\include\grpc++\channel_arguments.h"> + <ClInclude Include="..\..\include\grpc++\channel.h"> <Filter>include\grpc++</Filter> </ClInclude> - <ClInclude Include="..\..\include\grpc++\channel_interface.h"> + <ClInclude Include="..\..\include\grpc++\channel_arguments.h"> <Filter>include\grpc++</Filter> </ClInclude> <ClInclude Include="..\..\include\grpc++\client_context.h"> @@ -206,9 +206,6 @@ </ClInclude> </ItemGroup> <ItemGroup> - <ClInclude Include="..\..\src\cpp\client\channel.h"> - <Filter>src\cpp\client</Filter> - </ClInclude> <ClInclude Include="..\..\src\cpp\common\create_auth_context.h"> <Filter>src\cpp\common</Filter> </ClInclude> -- GitLab