From 3922005878625b97e008381f6933ab1778bf48ba Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 13 Jul 2015 16:18:19 -0700 Subject: Introduced InteropContextInspector to be able to peek into server contexts during interop testing. --- include/grpc++/server_context.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/grpc++/server_context.h') diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h index a2f0a2f990..5ea52b045d 100644 --- a/include/grpc++/server_context.h +++ b/include/grpc++/server_context.h @@ -75,6 +75,10 @@ class CallOpBuffer; class CompletionQueue; class Server; +namespace testing { +class InteropContextInspector; +} // namespace testing + // Interface of server side rpc context. class ServerContext { public: @@ -109,6 +113,7 @@ class ServerContext { void set_compression_algorithm(grpc_compression_algorithm algorithm); private: + friend class ::grpc::testing::InteropContextInspector; friend class ::grpc::Server; template friend class ::grpc::ServerAsyncReader; -- cgit v1.2.3 From 80f3995e47ae1ccd30a48c00ef8770cf18e51280 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 21 Jul 2015 16:07:36 -0700 Subject: wip --- include/grpc++/client_context.h | 5 +++++ include/grpc++/server_context.h | 4 ++-- test/cpp/interop/client_helper.cc | 31 ++++++++++++++++++++++++++- test/cpp/interop/client_helper.h | 18 ++++++++++++++++ test/cpp/interop/interop_client.cc | 44 +++++++++++++++++++++++--------------- test/cpp/interop/server.cc | 25 ++++++++++++++++++++-- test/cpp/interop/server_helper.cc | 8 +++---- test/cpp/interop/server_helper.h | 4 ++-- 8 files changed, 111 insertions(+), 28 deletions(-) (limited to 'include/grpc++/server_context.h') diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h index 9df76699d2..ccaf582d0a 100644 --- a/include/grpc++/client_context.h +++ b/include/grpc++/client_context.h @@ -71,6 +71,10 @@ class ClientAsyncReaderWriter; template class ClientAsyncResponseReader; +namespace testing { +class InteropClientContextInspector; +} // namespace testing + class ClientContext { public: ClientContext(); @@ -129,6 +133,7 @@ class ClientContext { ClientContext(const ClientContext&); ClientContext& operator=(const ClientContext&); + friend class ::grpc::testing::InteropClientContextInspector; friend class CallOpClientRecvStatus; friend class CallOpRecvInitialMetadata; friend class Channel; diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h index 3bfa48fbb6..268cd7ffc3 100644 --- a/include/grpc++/server_context.h +++ b/include/grpc++/server_context.h @@ -78,7 +78,7 @@ class CompletionQueue; class Server; namespace testing { -class InteropContextInspector; +class InteropServerContextInspector; } // namespace testing // Interface of server side rpc context. @@ -117,7 +117,7 @@ class ServerContext { std::shared_ptr auth_context() const; private: - friend class ::grpc::testing::InteropContextInspector; + friend class ::grpc::testing::InteropServerContextInspector; friend class ::grpc::Server; template friend class ::grpc::ServerAsyncReader; diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index 48b1b2e864..9df79bdbb5 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -48,10 +48,13 @@ #include #include #include -#include "src/cpp/client/secure_credentials.h" + #include "test/core/security/oauth2_utils.h" #include "test/cpp/util/create_test_channel.h" +#include "src/core/surface/call.h" +#include "src/cpp/client/secure_credentials.h" + DECLARE_bool(enable_ssl); DECLARE_bool(use_prod_roots); DECLARE_int32(server_port); @@ -62,6 +65,8 @@ DECLARE_string(default_service_account); DECLARE_string(service_account_key_file); DECLARE_string(oauth_scope); +using grpc::testing::CompressionType; + namespace grpc { namespace testing { @@ -137,5 +142,29 @@ std::shared_ptr CreateChannelForTestCase( } } +CompressionType GetInteropCompressionTypeFromCompressionAlgorithm( + grpc_compression_algorithm algorithm) { + switch (algorithm) { + case GRPC_COMPRESS_NONE: + return CompressionType::NONE; + case GRPC_COMPRESS_GZIP: + return CompressionType::GZIP; + case GRPC_COMPRESS_DEFLATE: + return CompressionType::DEFLATE; + default: + GPR_ASSERT(false); + } +} + +InteropClientContextInspector::InteropClientContextInspector( + const ::grpc::ClientContext& context) + : context_(context) {} + +grpc_compression_algorithm +InteropClientContextInspector::GetCallCompressionAlgorithm() const { + return grpc_call_get_compression_algorithm(context_.call_); +} + + } // namespace testing } // namespace grpc diff --git a/test/cpp/interop/client_helper.h b/test/cpp/interop/client_helper.h index c4361bb9de..fb8a6644e4 100644 --- a/test/cpp/interop/client_helper.h +++ b/test/cpp/interop/client_helper.h @@ -39,6 +39,8 @@ #include #include +#include "test/proto/messages.grpc.pb.h" + namespace grpc { namespace testing { @@ -49,6 +51,22 @@ grpc::string GetOauth2AccessToken(); std::shared_ptr CreateChannelForTestCase( const grpc::string& test_case); +grpc::testing::CompressionType +GetInteropCompressionTypeFromCompressionAlgorithm( + grpc_compression_algorithm algorithm); + +class InteropClientContextInspector { + public: + InteropClientContextInspector(const ::grpc::ClientContext& context); + + // Inspector methods, able to peek inside ClientContext, follow. + grpc_compression_algorithm GetCallCompressionAlgorithm() const; + + private: + const ::grpc::ClientContext& context_; +}; + + } // namespace testing } // namespace grpc diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index b53535bd46..3a28c704b5 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -43,6 +43,8 @@ #include #include #include + +#include "test/cpp/interop/client_helper.h" #include "test/proto/test.grpc.pb.h" #include "test/proto/empty.grpc.pb.h" #include "test/proto/messages.grpc.pb.h" @@ -93,24 +95,18 @@ void InteropClient::PerformLargeUnary(SimpleRequest* request, std::unique_ptr stub(TestService::NewStub(channel_)); ClientContext context; - // XXX: add UNCOMPRESSABLE to the mix - // - // XXX: 1) set request.response_compression to all the diff available - // compression values. We can't check the compression method used at the - // application level, but if something is wrong, two different implementations - // of gRPC (java vs c) won't be able to communicate. - // - // 2) for UNCOMPRESSABLE, verify that the response can be whatever, most - // likely uncompressed - request->set_response_type(PayloadType::COMPRESSABLE); + InteropClientContextInspector inspector(context); request->set_response_size(kLargeResponseSize); grpc::string payload(kLargeRequestSize, '\0'); request->mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); Status s = stub->UnaryCall(&context, *request, response); + GPR_ASSERT(request->response_compression() == + GetInteropCompressionTypeFromCompressionAlgorithm( + inspector.GetCallCompressionAlgorithm())); AssertOkOrPrintErrorStatus(s); - GPR_ASSERT(response->payload().type() == PayloadType::COMPRESSABLE); + GPR_ASSERT(response->payload().type() == request->response_type()); GPR_ASSERT(response->payload().body() == grpc::string(kLargeResponseSize, '\0')); } @@ -124,6 +120,7 @@ void InteropClient::DoComputeEngineCreds( SimpleResponse response; request.set_fill_username(true); request.set_fill_oauth_scope(true); + request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); gpr_log(GPR_INFO, "Got username %s", response.username().c_str()); gpr_log(GPR_INFO, "Got oauth_scope %s", response.oauth_scope().c_str()); @@ -143,6 +140,7 @@ void InteropClient::DoServiceAccountCreds(const grpc::string& username, SimpleResponse response; request.set_fill_username(true); request.set_fill_oauth_scope(true); + request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); GPR_ASSERT(!response.username().empty()); GPR_ASSERT(!response.oauth_scope().empty()); @@ -180,6 +178,7 @@ void InteropClient::DoJwtTokenCreds(const grpc::string& username) { SimpleRequest request; SimpleResponse response; request.set_fill_username(true); + request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); GPR_ASSERT(!response.username().empty()); GPR_ASSERT(username.find(response.username()) != grpc::string::npos); @@ -187,12 +186,19 @@ void InteropClient::DoJwtTokenCreds(const grpc::string& username) { } void InteropClient::DoLargeUnary() { - gpr_log(GPR_INFO, "Sending a large unary rpc..."); - SimpleRequest request; - request.set_response_compression(grpc::testing::GZIP); - SimpleResponse response; - PerformLargeUnary(&request, &response); - gpr_log(GPR_INFO, "Large unary done."); + const CompressionType compression_types[] = {NONE, GZIP, DEFLATE}; + const PayloadType payload_types[] = {COMPRESSABLE, UNCOMPRESSABLE, RANDOM}; + for (const auto payload_type : payload_types) { + for (const auto compression_type : compression_types) { + gpr_log(GPR_INFO, "Sending a large unary rpc..."); + SimpleRequest request; + SimpleResponse response; + request.set_response_type(payload_type); + request.set_response_compression(compression_type); + PerformLargeUnary(&request, &response); + gpr_log(GPR_INFO, "Large unary done."); + } + } } void InteropClient::DoRequestStreaming() { @@ -227,11 +233,15 @@ void InteropClient::DoResponseStreaming() { ClientContext context; StreamingOutputCallRequest request; + request.set_response_type(PayloadType::COMPRESSABLE); + request.set_response_compression(CompressionType::GZIP); + for (unsigned int i = 0; i < response_stream_sizes.size(); ++i) { ResponseParameters* response_parameter = request.add_response_parameters(); response_parameter->set_size(response_stream_sizes[i]); } StreamingOutputCallResponse response; + std::unique_ptr> stream( stub->StreamingOutputCall(&context, request)); diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc index 7605b2a6ff..55df82b567 100644 --- a/test/cpp/interop/server.cc +++ b/test/cpp/interop/server.cc @@ -81,8 +81,28 @@ static bool got_sigint = false; bool SetPayload(PayloadType type, int size, Payload* payload) { PayloadType response_type = type; payload->set_type(response_type); - std::unique_ptr body(new char[size]()); - payload->set_body(body.get(), size); + switch (type) { + case PayloadType::COMPRESSABLE: + { + std::unique_ptr body(new char[size]()); + payload->set_body(body.get(), size); + } + break; + case PayloadType::UNCOMPRESSABLE: + { + // XXX + std::unique_ptr body(new char[size]()); + payload->set_body(body.get(), size); + } + break; + case PayloadType::RANDOM: + { + // XXX + std::unique_ptr body(new char[size]()); + payload->set_body(body.get(), size); + } + break; + } return true; } @@ -122,6 +142,7 @@ class TestServiceImpl : public TestService::Service { return Status(grpc::StatusCode::INTERNAL, "Error creating payload."); } } + return Status::OK; } diff --git a/test/cpp/interop/server_helper.cc b/test/cpp/interop/server_helper.cc index 0f8e5ff4f6..8cfed2acb5 100644 --- a/test/cpp/interop/server_helper.cc +++ b/test/cpp/interop/server_helper.cc @@ -60,21 +60,21 @@ std::shared_ptr CreateInteropServerCredentials() { } } -InteropContextInspector::InteropContextInspector( +InteropServerContextInspector::InteropServerContextInspector( const ::grpc::ServerContext& context) : context_(context) {} grpc_compression_algorithm -InteropContextInspector::GetCallCompressionAlgorithm() const { +InteropServerContextInspector::GetCallCompressionAlgorithm() const { return grpc_call_get_compression_algorithm(context_.call_); } -std::shared_ptr InteropContextInspector::GetAuthContext() +std::shared_ptr InteropServerContextInspector::GetAuthContext() const { return context_.auth_context(); } -bool InteropContextInspector::IsCancelled() const { +bool InteropServerContextInspector::IsCancelled() const { return context_.IsCancelled(); } diff --git a/test/cpp/interop/server_helper.h b/test/cpp/interop/server_helper.h index 504652c885..a57ef0b3c5 100644 --- a/test/cpp/interop/server_helper.h +++ b/test/cpp/interop/server_helper.h @@ -45,9 +45,9 @@ namespace testing { std::shared_ptr CreateInteropServerCredentials(); -class InteropContextInspector { +class InteropServerContextInspector { public: - InteropContextInspector(const ::grpc::ServerContext& context); + InteropServerContextInspector(const ::grpc::ServerContext& context); // Inspector methods, able to peek inside ServerContext, follow. std::shared_ptr GetAuthContext() const; -- cgit v1.2.3 From 9b7757dd356dae2549433d5b2686ce9a902c7bcc Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 13 Aug 2015 11:15:53 -0700 Subject: Use a sync service to handle requests to unknown services --- include/grpc++/completion_queue.h | 2 ++ include/grpc++/impl/rpc_service_method.h | 15 +++++++++++ include/grpc++/server.h | 2 ++ include/grpc++/server_context.h | 2 ++ src/cpp/server/server.cc | 44 +++++++++++++++++++++++++++----- src/cpp/server/server_builder.cc | 7 +++++ test/cpp/end2end/async_end2end_test.cc | 22 ++++++++++++++++ test/cpp/end2end/end2end_test.cc | 23 ++++++++++++++++- test/cpp/util/echo.proto | 4 +++ 9 files changed, 113 insertions(+), 8 deletions(-) (limited to 'include/grpc++/server_context.h') diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h index 0523ab6a0e..2f30211145 100644 --- a/include/grpc++/completion_queue.h +++ b/include/grpc++/completion_queue.h @@ -63,6 +63,7 @@ template class ServerStreamingHandler; template class BidiStreamingHandler; +class UnknownMethodHandler; class ChannelInterface; class ClientContext; @@ -138,6 +139,7 @@ class CompletionQueue : public GrpcLibrary { friend class ServerStreamingHandler; template friend class BidiStreamingHandler; + friend class UnknownMethodHandler; friend class ::grpc::Server; friend class ::grpc::ServerContext; template diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h index 3cfbef7806..925801e1ce 100644 --- a/include/grpc++/impl/rpc_service_method.h +++ b/include/grpc++/impl/rpc_service_method.h @@ -208,6 +208,21 @@ class BidiStreamingHandler : public MethodHandler { ServiceType* service_; }; +// Handle unknown method by returning UNIMPLEMENTED error. +class UnknownMethodHandler : public MethodHandler { + public: + void RunHandler(const HandlerParameter& param) GRPC_FINAL { + Status status(StatusCode::UNIMPLEMENTED, ""); + CallOpSet ops; + if (!param.server_context->sent_initial_metadata_) { + ops.SendInitialMetadata(param.server_context->initial_metadata_); + } + ops.ServerSendStatus(param.server_context->trailing_metadata_, status); + param.call->PerformOps(&ops); + param.call->cq()->Pluck(&ops); + } +}; + // Server side rpc method class class RpcServiceMethod : public RpcMethod { public: diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 94ee0b6a4a..8755b4b445 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -228,6 +228,8 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { grpc::condition_variable callback_cv_; std::list* sync_methods_; + std::unique_ptr unknown_method_; + bool has_generic_service_; // Pointer to the c grpc server. grpc_server* const server_; diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h index 4f7fc54ef1..8262dee654 100644 --- a/include/grpc++/server_context.h +++ b/include/grpc++/server_context.h @@ -73,6 +73,7 @@ template class ServerStreamingHandler; template class BidiStreamingHandler; +class UnknownMethodHandler; class Call; class CallOpBuffer; @@ -159,6 +160,7 @@ class ServerContext { friend class ServerStreamingHandler; template friend class BidiStreamingHandler; + friend class UnknownMethodHandler; friend class ::grpc::ClientContext; // Prevent copying. diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index ab87b22f5f..c054eb0a7d 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -67,11 +67,17 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { has_request_payload_(method->method_type() == RpcMethod::NORMAL_RPC || method->method_type() == RpcMethod::SERVER_STREAMING), + call_details_(nullptr), cq_(nullptr) { grpc_metadata_array_init(&request_metadata_); } - ~SyncRequest() { grpc_metadata_array_destroy(&request_metadata_); } + ~SyncRequest() { + if (call_details_) { + delete call_details_; + } + grpc_metadata_array_destroy(&request_metadata_); + } static SyncRequest* Wait(CompletionQueue* cq, bool* ok) { void* tag = nullptr; @@ -94,17 +100,32 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { void Request(grpc_server* server, grpc_completion_queue* notify_cq) { GPR_ASSERT(cq_ && !in_flight_); in_flight_ = true; - GPR_ASSERT(GRPC_CALL_OK == - grpc_server_request_registered_call( - server, tag_, &call_, &deadline_, &request_metadata_, - has_request_payload_ ? &request_payload_ : nullptr, cq_, - notify_cq, this)); + if (tag_) { + GPR_ASSERT(GRPC_CALL_OK == + grpc_server_request_registered_call( + server, tag_, &call_, &deadline_, &request_metadata_, + has_request_payload_ ? &request_payload_ : nullptr, cq_, + notify_cq, this)); + } else { + if (!call_details_) { + call_details_ = new grpc_call_details; + grpc_call_details_init(call_details_); + } + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + server, &call_, call_details_, + &request_metadata_, cq_, notify_cq, this)); + } } bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { if (!*status) { grpc_completion_queue_destroy(cq_); } + if (call_details_) { + deadline_ = call_details_->deadline; + grpc_call_details_destroy(call_details_); + grpc_call_details_init(call_details_); + } return true; } @@ -157,6 +178,7 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { bool in_flight_; const bool has_request_payload_; grpc_call* call_; + grpc_call_details* call_details_; gpr_timespec deadline_; grpc_metadata_array request_metadata_; grpc_byte_buffer* request_payload_; @@ -183,6 +205,7 @@ Server::Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned, shutdown_(false), num_running_cb_(0), sync_methods_(new std::list), + has_generic_service_(false), server_(CreateServer(max_message_size)), thread_pool_(thread_pool), thread_pool_owned_(thread_pool_owned) { @@ -223,7 +246,8 @@ bool Server::RegisterService(const grpc::string *host, RpcService* service) { return true; } -bool Server::RegisterAsyncService(const grpc::string *host, AsynchronousService* service) { +bool Server::RegisterAsyncService(const grpc::string* host, + AsynchronousService* service) { GPR_ASSERT(service->server_ == nullptr && "Can only register an asynchronous service against one server."); service->server_ = this; @@ -245,6 +269,7 @@ void Server::RegisterAsyncGenericService(AsyncGenericService* service) { GPR_ASSERT(service->server_ == nullptr && "Can only register an async generic service against one server."); service->server_ = this; + has_generic_service_ = true; } int Server::AddListeningPort(const grpc::string& addr, @@ -258,6 +283,11 @@ bool Server::Start() { started_ = true; grpc_server_start(server_); + if (!has_generic_service_) { + unknown_method_.reset(new RpcServiceMethod( + "unknown", RpcMethod::BIDI_STREAMING, new UnknownMethodHandler)); + sync_methods_->emplace_back(SyncRequest(unknown_method_.get(), nullptr)); + } // Start processing rpcs. if (!sync_methods_->empty()) { for (auto m = sync_methods_->begin(); m != sync_methods_->end(); m++) { diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index f723d4611a..fd97ad082c 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -38,6 +38,7 @@ #include #include #include +#include namespace grpc { @@ -100,6 +101,12 @@ std::unique_ptr ServerBuilder::BuildAndStart() { thread_pool_ = CreateDefaultThreadPool(); thread_pool_owned = true; } + // Async services only, create a thread pool to handle requests to unknown + // services. + if (!thread_pool_ && !generic_service_ && !async_services_.empty()) { + thread_pool_ = new FixedSizeThreadPool(1); + thread_pool_owned = true; + } std::unique_ptr server( new Server(thread_pool_, thread_pool_owned, max_message_size_)); for (auto cq = cqs_.begin(); cq != cqs_.end(); ++cq) { diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 9b53bdc999..f00d19ed6c 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -666,6 +666,28 @@ TEST_F(AsyncEnd2endTest, ServerCheckDone) { EXPECT_TRUE(recv_status.ok()); } +TEST_F(AsyncEnd2endTest, UnimplementedRpc) { + std::shared_ptr channel = CreateChannel( + server_address_.str(), InsecureCredentials(), ChannelArguments()); + std::unique_ptr stub; + stub = + std::move(grpc::cpp::test::util::UnimplementedService::NewStub(channel)); + EchoRequest send_request; + EchoResponse recv_response; + Status recv_status; + + ClientContext cli_ctx; + send_request.set_message("Hello"); + std::unique_ptr > response_reader( + stub->AsyncUnimplemented(&cli_ctx, send_request, cq_.get())); + + response_reader->Finish(&recv_response, &recv_status, tag(4)); + Verifier().Expect(4, false).Verify(cq_.get()); + + EXPECT_EQ(StatusCode::UNIMPLEMENTED, recv_status.error_code()); + EXPECT_EQ("", recv_status.error_message()); +} + } // namespace } // namespace testing } // namespace grpc diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 5f0749daa5..1eb3416be9 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -290,13 +290,17 @@ class End2endTest : public ::testing::TestWithParam { if (proxy_server_) proxy_server_->Shutdown(); } - void ResetStub(bool use_proxy) { + void ResetChannel() { SslCredentialsOptions ssl_opts = {test_root_cert, "", ""}; ChannelArguments args; args.SetSslTargetNameOverride("foo.test.google.fr"); args.SetString(GRPC_ARG_SECONDARY_USER_AGENT_STRING, "end2end_test"); channel_ = CreateChannel(server_address_.str(), SslCredentials(ssl_opts), args); + } + + void ResetStub(bool use_proxy) { + ResetChannel(); if (use_proxy) { proxy_service_.reset(new Proxy(channel_)); int port = grpc_pick_unused_port_or_die(); @@ -930,6 +934,23 @@ TEST_F(End2endTest, ChannelState) { EXPECT_EQ(GRPC_CHANNEL_CONNECTING, channel_->GetState(false)); } +// Talking to a non-existing service. +TEST_F(End2endTest, NonExistingService) { + ResetChannel(); + std::unique_ptr stub; + stub = + std::move(grpc::cpp::test::util::UnimplementedService::NewStub(channel_)); + + EchoRequest request; + EchoResponse response; + request.set_message("Hello"); + + ClientContext context; + Status s = stub->Unimplemented(&context, request, &response); + EXPECT_EQ(StatusCode::UNIMPLEMENTED, s.error_code()); + EXPECT_EQ("", s.error_message()); +} + INSTANTIATE_TEST_CASE_P(End2end, End2endTest, ::testing::Values(false, true)); } // namespace testing diff --git a/test/cpp/util/echo.proto b/test/cpp/util/echo.proto index 58ec680ecd..8d187c5617 100644 --- a/test/cpp/util/echo.proto +++ b/test/cpp/util/echo.proto @@ -41,3 +41,7 @@ service TestService { rpc BidiStream(stream EchoRequest) returns (stream EchoResponse); rpc Unimplemented(EchoRequest) returns (EchoResponse); } + +service UnimplementedService { + rpc Unimplemented(EchoRequest) returns (EchoResponse); +} -- cgit v1.2.3 From 9e2f90cd068b4c2a8fdec69ca93ca614d35cba28 Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 21 Aug 2015 15:35:03 -0700 Subject: headers reorg --- BUILD | 68 +- Makefile | 68 +- build.json | 34 +- examples/pubsub/main.cc | 6 +- examples/pubsub/publisher.h | 1 - examples/pubsub/publisher_test.cc | 2 - examples/pubsub/subscriber.h | 1 - examples/pubsub/subscriber_test.cc | 2 - include/grpc++/async_generic_service.h | 78 --- include/grpc++/async_unary_call.h | 155 ---- include/grpc++/auth_context.h | 95 --- include/grpc++/byte_buffer.h | 104 --- include/grpc++/channel.h | 2 +- include/grpc++/channel_arguments.h | 93 --- include/grpc++/client_context.h | 8 +- include/grpc++/completion_queue.h | 4 +- include/grpc++/config.h | 116 --- include/grpc++/config_protobuf.h | 72 -- include/grpc++/create_channel.h | 4 +- include/grpc++/credentials.h | 2 +- include/grpc++/dynamic_thread_pool.h | 83 --- include/grpc++/fixed_size_thread_pool.h | 67 -- include/grpc++/generic/async_generic_service.h | 78 +++ include/grpc++/generic/generic_stub.h | 63 ++ include/grpc++/generic_stub.h | 63 -- include/grpc++/impl/call.h | 15 +- include/grpc++/impl/client_unary_call.h | 5 +- include/grpc++/impl/proto_utils.h | 4 +- include/grpc++/impl/rpc_service_method.h | 6 +- include/grpc++/impl/service_type.h | 4 +- include/grpc++/impl/sync.h | 2 +- include/grpc++/impl/thd.h | 2 +- include/grpc++/server.h | 4 +- include/grpc++/server_builder.h | 2 +- include/grpc++/server_context.h | 6 +- include/grpc++/server_credentials.h | 2 +- include/grpc++/slice.h | 74 -- include/grpc++/status.h | 64 -- include/grpc++/status_code_enum.h | 159 ----- include/grpc++/stream.h | 776 --------------------- include/grpc++/stub_options.h | 43 -- include/grpc++/support/async_unary_call.h | 155 ++++ include/grpc++/support/auth_context.h | 95 +++ include/grpc++/support/byte_buffer.h | 104 +++ include/grpc++/support/channel_arguments.h | 93 +++ include/grpc++/support/config.h | 116 +++ include/grpc++/support/config_protobuf.h | 72 ++ include/grpc++/support/dynamic_thread_pool.h | 82 +++ include/grpc++/support/fixed_size_thread_pool.h | 66 ++ include/grpc++/support/slice.h | 74 ++ include/grpc++/support/status.h | 64 ++ include/grpc++/support/status_code_enum.h | 159 +++++ include/grpc++/support/stream.h | 776 +++++++++++++++++++++ include/grpc++/support/stub_options.h | 43 ++ include/grpc++/support/thread_pool_interface.h | 54 ++ include/grpc++/support/time.h | 110 +++ include/grpc++/thread_pool_interface.h | 54 -- include/grpc++/time.h | 110 --- src/compiler/config.h | 4 +- src/compiler/cpp_generator.cc | 12 +- src/compiler/python_generator.cc | 2 +- src/cpp/client/channel.cc | 11 +- src/cpp/client/channel_arguments.cc | 3 +- src/cpp/client/client_context.cc | 2 +- src/cpp/client/create_channel.cc | 2 +- src/cpp/client/create_channel_internal.h | 2 +- src/cpp/client/generic_stub.cc | 2 +- src/cpp/client/insecure_credentials.cc | 8 +- src/cpp/client/secure_channel_arguments.cc | 4 +- src/cpp/client/secure_credentials.cc | 2 +- src/cpp/client/secure_credentials.h | 2 +- src/cpp/common/auth_property_iterator.cc | 2 +- src/cpp/common/call.cc | 5 +- src/cpp/common/completion_queue.cc | 2 +- src/cpp/common/create_auth_context.h | 2 +- src/cpp/common/insecure_create_auth_context.cc | 2 +- src/cpp/common/secure_auth_context.h | 2 +- src/cpp/common/secure_create_auth_context.cc | 2 +- src/cpp/proto/proto_utils.cc | 2 +- src/cpp/server/async_generic_service.cc | 2 +- src/cpp/server/create_default_thread_pool.cc | 2 +- src/cpp/server/dynamic_thread_pool.cc | 2 +- src/cpp/server/fixed_size_thread_pool.cc | 2 +- src/cpp/server/secure_server_credentials.h | 4 +- src/cpp/server/server.cc | 7 +- src/cpp/server/server_builder.cc | 4 +- src/cpp/server/server_context.cc | 2 +- src/cpp/util/byte_buffer.cc | 2 +- src/cpp/util/slice.cc | 2 +- src/cpp/util/status.cc | 2 +- src/cpp/util/time.cc | 4 +- test/cpp/client/channel_arguments_test.cc | 2 +- test/cpp/common/auth_property_iterator_test.cc | 2 +- test/cpp/common/secure_auth_context_test.cc | 2 +- test/cpp/end2end/async_end2end_test.cc | 19 +- test/cpp/end2end/client_crash_test.cc | 19 +- test/cpp/end2end/client_crash_test_server.cc | 1 - test/cpp/end2end/end2end_test.cc | 24 +- test/cpp/end2end/generic_end2end_test.cc | 24 +- test/cpp/end2end/mock_test.cc | 20 +- test/cpp/end2end/server_crash_test.cc | 19 +- test/cpp/end2end/server_crash_test_client.cc | 2 - test/cpp/end2end/shutdown_test.cc | 16 +- test/cpp/end2end/thread_stress_test.cc | 20 +- test/cpp/end2end/zookeeper_test.cc | 11 +- test/cpp/interop/client.cc | 3 +- test/cpp/interop/client_helper.cc | 9 +- test/cpp/interop/client_helper.h | 1 - test/cpp/interop/interop_client.cc | 8 +- test/cpp/interop/interop_client.h | 2 +- test/cpp/interop/interop_test.cc | 11 +- test/cpp/interop/reconnect_interop_client.cc | 1 - test/cpp/interop/reconnect_interop_server.cc | 9 +- test/cpp/interop/server.cc | 14 +- test/cpp/interop/server_helper.cc | 1 - test/cpp/qps/client.h | 8 +- test/cpp/qps/client_async.cc | 6 +- test/cpp/qps/client_sync.cc | 9 +- test/cpp/qps/driver.cc | 22 +- test/cpp/qps/interarrival.h | 2 +- test/cpp/qps/perf_db_client.h | 3 +- test/cpp/qps/qps_interarrival_test.cc | 4 +- test/cpp/qps/qps_openloop_test.cc | 4 +- test/cpp/qps/qps_test.cc | 4 +- test/cpp/qps/qps_test_with_poll.cc | 4 +- test/cpp/qps/qps_worker.cc | 5 +- test/cpp/qps/report.h | 3 +- test/cpp/qps/server_async.cc | 10 +- test/cpp/qps/server_sync.cc | 15 +- test/cpp/qps/stats.h | 3 +- test/cpp/qps/sync_streaming_ping_pong_test.cc | 4 +- test/cpp/qps/sync_unary_ping_pong_test.cc | 4 +- test/cpp/qps/timer.cc | 1 - test/cpp/qps/worker.cc | 2 +- test/cpp/server/dynamic_thread_pool_test.cc | 3 +- test/cpp/server/fixed_size_thread_pool_test.cc | 3 +- test/cpp/util/byte_buffer_test.cc | 4 +- test/cpp/util/cli_call.cc | 11 +- test/cpp/util/cli_call.h | 3 +- test/cpp/util/cli_call_test.cc | 13 +- test/cpp/util/create_test_channel.cc | 4 +- test/cpp/util/create_test_channel.h | 1 - test/cpp/util/grpc_cli.cc | 7 +- test/cpp/util/slice_test.cc | 2 +- test/cpp/util/status_test.cc | 3 +- test/cpp/util/time_test.cc | 2 +- tools/doxygen/Doxyfile.c++ | 36 +- tools/doxygen/Doxyfile.c++.internal | 36 +- tools/run_tests/sources_and_headers.json | 136 ++-- vsprojects/grpc++/grpc++.vcxproj | 34 +- vsprojects/grpc++/grpc++.vcxproj.filters | 90 +-- vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj | 34 +- .../grpc++_unsecure.vcxproj.filters | 90 +-- 153 files changed, 2786 insertions(+), 2853 deletions(-) delete mode 100644 include/grpc++/async_generic_service.h delete mode 100644 include/grpc++/async_unary_call.h delete mode 100644 include/grpc++/auth_context.h delete mode 100644 include/grpc++/byte_buffer.h delete mode 100644 include/grpc++/channel_arguments.h delete mode 100644 include/grpc++/config.h delete mode 100644 include/grpc++/config_protobuf.h delete mode 100644 include/grpc++/dynamic_thread_pool.h delete mode 100644 include/grpc++/fixed_size_thread_pool.h create mode 100644 include/grpc++/generic/async_generic_service.h create mode 100644 include/grpc++/generic/generic_stub.h delete mode 100644 include/grpc++/generic_stub.h delete mode 100644 include/grpc++/slice.h delete mode 100644 include/grpc++/status.h delete mode 100644 include/grpc++/status_code_enum.h delete mode 100644 include/grpc++/stream.h delete mode 100644 include/grpc++/stub_options.h create mode 100644 include/grpc++/support/async_unary_call.h create mode 100644 include/grpc++/support/auth_context.h create mode 100644 include/grpc++/support/byte_buffer.h create mode 100644 include/grpc++/support/channel_arguments.h create mode 100644 include/grpc++/support/config.h create mode 100644 include/grpc++/support/config_protobuf.h create mode 100644 include/grpc++/support/dynamic_thread_pool.h create mode 100644 include/grpc++/support/fixed_size_thread_pool.h create mode 100644 include/grpc++/support/slice.h create mode 100644 include/grpc++/support/status.h create mode 100644 include/grpc++/support/status_code_enum.h create mode 100644 include/grpc++/support/stream.h create mode 100644 include/grpc++/support/stub_options.h create mode 100644 include/grpc++/support/thread_pool_interface.h create mode 100644 include/grpc++/support/time.h delete mode 100644 include/grpc++/thread_pool_interface.h delete mode 100644 include/grpc++/time.h (limited to 'include/grpc++/server_context.h') diff --git a/BUILD b/BUILD index d712053a3d..620a954a5a 100644 --- a/BUILD +++ b/BUILD @@ -710,21 +710,13 @@ cc_library( "src/cpp/util/time.cc", ], hdrs = [ - "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++/client_context.h", "include/grpc++/completion_queue.h", - "include/grpc++/config.h", - "include/grpc++/config_protobuf.h", "include/grpc++/create_channel.h", "include/grpc++/credentials.h", - "include/grpc++/dynamic_thread_pool.h", - "include/grpc++/fixed_size_thread_pool.h", - "include/grpc++/generic_stub.h", + "include/grpc++/generic/async_generic_service.h", + "include/grpc++/generic/generic_stub.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/grpc_library.h", @@ -743,13 +735,21 @@ cc_library( "include/grpc++/server_builder.h", "include/grpc++/server_context.h", "include/grpc++/server_credentials.h", - "include/grpc++/slice.h", - "include/grpc++/status.h", - "include/grpc++/status_code_enum.h", - "include/grpc++/stream.h", - "include/grpc++/stub_options.h", - "include/grpc++/thread_pool_interface.h", - "include/grpc++/time.h", + "include/grpc++/support/async_unary_call.h", + "include/grpc++/support/auth_context.h", + "include/grpc++/support/byte_buffer.h", + "include/grpc++/support/channel_arguments.h", + "include/grpc++/support/config.h", + "include/grpc++/support/config_protobuf.h", + "include/grpc++/support/dynamic_thread_pool.h", + "include/grpc++/support/fixed_size_thread_pool.h", + "include/grpc++/support/slice.h", + "include/grpc++/support/status.h", + "include/grpc++/support/status_code_enum.h", + "include/grpc++/support/stream.h", + "include/grpc++/support/stub_options.h", + "include/grpc++/support/thread_pool_interface.h", + "include/grpc++/support/time.h", ], includes = [ "include", @@ -796,21 +796,13 @@ cc_library( "src/cpp/util/time.cc", ], hdrs = [ - "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++/client_context.h", "include/grpc++/completion_queue.h", - "include/grpc++/config.h", - "include/grpc++/config_protobuf.h", "include/grpc++/create_channel.h", "include/grpc++/credentials.h", - "include/grpc++/dynamic_thread_pool.h", - "include/grpc++/fixed_size_thread_pool.h", - "include/grpc++/generic_stub.h", + "include/grpc++/generic/async_generic_service.h", + "include/grpc++/generic/generic_stub.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/grpc_library.h", @@ -829,13 +821,21 @@ cc_library( "include/grpc++/server_builder.h", "include/grpc++/server_context.h", "include/grpc++/server_credentials.h", - "include/grpc++/slice.h", - "include/grpc++/status.h", - "include/grpc++/status_code_enum.h", - "include/grpc++/stream.h", - "include/grpc++/stub_options.h", - "include/grpc++/thread_pool_interface.h", - "include/grpc++/time.h", + "include/grpc++/support/async_unary_call.h", + "include/grpc++/support/auth_context.h", + "include/grpc++/support/byte_buffer.h", + "include/grpc++/support/channel_arguments.h", + "include/grpc++/support/config.h", + "include/grpc++/support/config_protobuf.h", + "include/grpc++/support/dynamic_thread_pool.h", + "include/grpc++/support/fixed_size_thread_pool.h", + "include/grpc++/support/slice.h", + "include/grpc++/support/status.h", + "include/grpc++/support/status_code_enum.h", + "include/grpc++/support/stream.h", + "include/grpc++/support/stub_options.h", + "include/grpc++/support/thread_pool_interface.h", + "include/grpc++/support/time.h", ], includes = [ "include", diff --git a/Makefile b/Makefile index 5cce835c02..9dffab01c0 100644 --- a/Makefile +++ b/Makefile @@ -4629,21 +4629,13 @@ LIBGRPC++_SRC = \ src/cpp/util/time.cc \ PUBLIC_HEADERS_CXX += \ - 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++/client_context.h \ include/grpc++/completion_queue.h \ - include/grpc++/config.h \ - include/grpc++/config_protobuf.h \ include/grpc++/create_channel.h \ include/grpc++/credentials.h \ - include/grpc++/dynamic_thread_pool.h \ - include/grpc++/fixed_size_thread_pool.h \ - include/grpc++/generic_stub.h \ + include/grpc++/generic/async_generic_service.h \ + include/grpc++/generic/generic_stub.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ include/grpc++/impl/grpc_library.h \ @@ -4662,13 +4654,21 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/server_builder.h \ include/grpc++/server_context.h \ include/grpc++/server_credentials.h \ - include/grpc++/slice.h \ - include/grpc++/status.h \ - include/grpc++/status_code_enum.h \ - include/grpc++/stream.h \ - include/grpc++/stub_options.h \ - include/grpc++/thread_pool_interface.h \ - include/grpc++/time.h \ + include/grpc++/support/async_unary_call.h \ + include/grpc++/support/auth_context.h \ + include/grpc++/support/byte_buffer.h \ + include/grpc++/support/channel_arguments.h \ + include/grpc++/support/config.h \ + include/grpc++/support/config_protobuf.h \ + include/grpc++/support/dynamic_thread_pool.h \ + include/grpc++/support/fixed_size_thread_pool.h \ + include/grpc++/support/slice.h \ + include/grpc++/support/status.h \ + include/grpc++/support/status_code_enum.h \ + include/grpc++/support/stream.h \ + include/grpc++/support/stub_options.h \ + include/grpc++/support/thread_pool_interface.h \ + include/grpc++/support/time.h \ LIBGRPC++_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_SRC)))) @@ -4871,21 +4871,13 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/util/time.cc \ PUBLIC_HEADERS_CXX += \ - 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++/client_context.h \ include/grpc++/completion_queue.h \ - include/grpc++/config.h \ - include/grpc++/config_protobuf.h \ include/grpc++/create_channel.h \ include/grpc++/credentials.h \ - include/grpc++/dynamic_thread_pool.h \ - include/grpc++/fixed_size_thread_pool.h \ - include/grpc++/generic_stub.h \ + include/grpc++/generic/async_generic_service.h \ + include/grpc++/generic/generic_stub.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ include/grpc++/impl/grpc_library.h \ @@ -4904,13 +4896,21 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/server_builder.h \ include/grpc++/server_context.h \ include/grpc++/server_credentials.h \ - include/grpc++/slice.h \ - include/grpc++/status.h \ - include/grpc++/status_code_enum.h \ - include/grpc++/stream.h \ - include/grpc++/stub_options.h \ - include/grpc++/thread_pool_interface.h \ - include/grpc++/time.h \ + include/grpc++/support/async_unary_call.h \ + include/grpc++/support/auth_context.h \ + include/grpc++/support/byte_buffer.h \ + include/grpc++/support/channel_arguments.h \ + include/grpc++/support/config.h \ + include/grpc++/support/config_protobuf.h \ + include/grpc++/support/dynamic_thread_pool.h \ + include/grpc++/support/fixed_size_thread_pool.h \ + include/grpc++/support/slice.h \ + include/grpc++/support/status.h \ + include/grpc++/support/status_code_enum.h \ + include/grpc++/support/stream.h \ + include/grpc++/support/stub_options.h \ + include/grpc++/support/thread_pool_interface.h \ + include/grpc++/support/time.h \ LIBGRPC++_UNSECURE_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_UNSECURE_SRC)))) diff --git a/build.json b/build.json index 484502bf34..8eb4f37703 100644 --- a/build.json +++ b/build.json @@ -30,21 +30,13 @@ { "name": "grpc++_base", "public_headers": [ - "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++/client_context.h", "include/grpc++/completion_queue.h", - "include/grpc++/config.h", - "include/grpc++/config_protobuf.h", "include/grpc++/create_channel.h", "include/grpc++/credentials.h", - "include/grpc++/dynamic_thread_pool.h", - "include/grpc++/fixed_size_thread_pool.h", - "include/grpc++/generic_stub.h", + "include/grpc++/generic/async_generic_service.h", + "include/grpc++/generic/generic_stub.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/grpc_library.h", @@ -63,13 +55,21 @@ "include/grpc++/server_builder.h", "include/grpc++/server_context.h", "include/grpc++/server_credentials.h", - "include/grpc++/slice.h", - "include/grpc++/status.h", - "include/grpc++/status_code_enum.h", - "include/grpc++/stream.h", - "include/grpc++/stub_options.h", - "include/grpc++/thread_pool_interface.h", - "include/grpc++/time.h" + "include/grpc++/support/async_unary_call.h", + "include/grpc++/support/auth_context.h", + "include/grpc++/support/byte_buffer.h", + "include/grpc++/support/channel_arguments.h", + "include/grpc++/support/config.h", + "include/grpc++/support/config_protobuf.h", + "include/grpc++/support/dynamic_thread_pool.h", + "include/grpc++/support/fixed_size_thread_pool.h", + "include/grpc++/support/slice.h", + "include/grpc++/support/status.h", + "include/grpc++/support/status_code_enum.h", + "include/grpc++/support/stream.h", + "include/grpc++/support/stub_options.h", + "include/grpc++/support/thread_pool_interface.h", + "include/grpc++/support/time.h" ], "headers": [ "src/cpp/client/create_channel_internal.h", diff --git a/examples/pubsub/main.cc b/examples/pubsub/main.cc index fcee3b316b..32102dcb5c 100644 --- a/examples/pubsub/main.cc +++ b/examples/pubsub/main.cc @@ -37,18 +37,16 @@ #include #include +#include #include #include -#include -#include #include #include #include -#include -#include "test/cpp/util/test_config.h" #include "examples/pubsub/publisher.h" #include "examples/pubsub/subscriber.h" +#include "test/cpp/util/test_config.h" DEFINE_int32(server_port, 443, "Server port."); DEFINE_string(server_host, "pubsub-staging.googleapis.com", diff --git a/examples/pubsub/publisher.h b/examples/pubsub/publisher.h index b98e6973dc..02e6194b0b 100644 --- a/examples/pubsub/publisher.h +++ b/examples/pubsub/publisher.h @@ -35,7 +35,6 @@ #define GRPC_EXAMPLES_PUBSUB_PUBLISHER_H #include -#include #include "examples/pubsub/pubsub.grpc.pb.h" diff --git a/examples/pubsub/publisher_test.cc b/examples/pubsub/publisher_test.cc index 972b426e64..c2eb295ef2 100644 --- a/examples/pubsub/publisher_test.cc +++ b/examples/pubsub/publisher_test.cc @@ -31,7 +31,6 @@ * */ -#include #include #include #include @@ -39,7 +38,6 @@ #include #include #include -#include #include #include "examples/pubsub/publisher.h" diff --git a/examples/pubsub/subscriber.h b/examples/pubsub/subscriber.h index 87c833102c..c5b1df0d3e 100644 --- a/examples/pubsub/subscriber.h +++ b/examples/pubsub/subscriber.h @@ -35,7 +35,6 @@ #define GRPC_EXAMPLES_PUBSUB_SUBSCRIBER_H #include -#include #include "examples/pubsub/pubsub.grpc.pb.h" diff --git a/examples/pubsub/subscriber_test.cc b/examples/pubsub/subscriber_test.cc index 7974ca88c2..c5a077f407 100644 --- a/examples/pubsub/subscriber_test.cc +++ b/examples/pubsub/subscriber_test.cc @@ -31,7 +31,6 @@ * */ -#include #include #include #include @@ -39,7 +38,6 @@ #include #include #include -#include #include #include "examples/pubsub/subscriber.h" diff --git a/include/grpc++/async_generic_service.h b/include/grpc++/async_generic_service.h deleted file mode 100644 index b435c6e73d..0000000000 --- a/include/grpc++/async_generic_service.h +++ /dev/null @@ -1,78 +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 GRPCXX_ASYNC_GENERIC_SERVICE_H -#define GRPCXX_ASYNC_GENERIC_SERVICE_H - -#include -#include - -struct grpc_server; - -namespace grpc { - -typedef ServerAsyncReaderWriter - GenericServerAsyncReaderWriter; - -class GenericServerContext GRPC_FINAL : public ServerContext { - public: - const grpc::string& method() const { return method_; } - const grpc::string& host() const { return host_; } - - private: - friend class Server; - - grpc::string method_; - grpc::string host_; -}; - -class AsyncGenericService GRPC_FINAL { - public: - // TODO(yangg) Once we can add multiple completion queues to the server - // in c core, add a CompletionQueue* argument to the ctor here. - // TODO(yangg) support methods list. - AsyncGenericService(const grpc::string& methods) : server_(nullptr) {} - - void RequestCall(GenericServerContext* ctx, - GenericServerAsyncReaderWriter* reader_writer, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag); - - private: - friend class Server; - Server* server_; -}; - -} // namespace grpc - -#endif // GRPCXX_ASYNC_GENERIC_SERVICE_H diff --git a/include/grpc++/async_unary_call.h b/include/grpc++/async_unary_call.h deleted file mode 100644 index 4e1dd15f32..0000000000 --- a/include/grpc++/async_unary_call.h +++ /dev/null @@ -1,155 +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 GRPCXX_ASYNC_UNARY_CALL_H -#define GRPCXX_ASYNC_UNARY_CALL_H - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace grpc { - -template -class ClientAsyncResponseReaderInterface { - public: - virtual ~ClientAsyncResponseReaderInterface() {} - virtual void ReadInitialMetadata(void* tag) = 0; - virtual void Finish(R* msg, Status* status, void* tag) = 0; -}; - -template -class ClientAsyncResponseReader GRPC_FINAL - : public ClientAsyncResponseReaderInterface { - public: - template - ClientAsyncResponseReader(Channel* channel, CompletionQueue* cq, - const RpcMethod& method, ClientContext* context, - const W& request) - : context_(context), call_(channel->CreateCall(method, context, cq)) { - init_buf_.SendInitialMetadata(context->send_initial_metadata_); - // TODO(ctiller): don't assert - GPR_ASSERT(init_buf_.SendMessage(request).ok()); - init_buf_.ClientSendClose(); - call_.PerformOps(&init_buf_); - } - - void ReadInitialMetadata(void* tag) { - GPR_ASSERT(!context_->initial_metadata_received_); - - meta_buf_.set_output_tag(tag); - meta_buf_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_buf_); - } - - void Finish(R* msg, Status* status, void* tag) { - finish_buf_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_buf_.RecvInitialMetadata(context_); - } - finish_buf_.RecvMessage(msg); - finish_buf_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_buf_); - } - - private: - ClientContext* context_; - Call call_; - SneakyCallOpSet init_buf_; - CallOpSet meta_buf_; - CallOpSet, - CallOpClientRecvStatus> finish_buf_; -}; - -template -class ServerAsyncResponseWriter GRPC_FINAL - : public ServerAsyncStreamingInterface { - public: - explicit ServerAsyncResponseWriter(ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - void SendInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!ctx_->sent_initial_metadata_); - - meta_buf_.set_output_tag(tag); - meta_buf_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_buf_); - } - - void Finish(const W& msg, const Status& status, void* tag) { - finish_buf_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_buf_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (status.ok()) { - finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, - finish_buf_.SendMessage(msg)); - } else { - finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, status); - } - call_.PerformOps(&finish_buf_); - } - - void FinishWithError(const Status& status, void* tag) { - GPR_ASSERT(!status.ok()); - finish_buf_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_buf_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_buf_); - } - - private: - void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } - - Call call_; - ServerContext* ctx_; - CallOpSet meta_buf_; - CallOpSet finish_buf_; -}; - -} // namespace grpc - -#endif // GRPCXX_ASYNC_UNARY_CALL_H diff --git a/include/grpc++/auth_context.h b/include/grpc++/auth_context.h deleted file mode 100644 index 7dced90ce5..0000000000 --- a/include/grpc++/auth_context.h +++ /dev/null @@ -1,95 +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 GRPCXX_AUTH_CONTEXT_H -#define GRPCXX_AUTH_CONTEXT_H - -#include -#include - -#include - -struct grpc_auth_context; -struct grpc_auth_property; -struct grpc_auth_property_iterator; - -namespace grpc { -class SecureAuthContext; - -typedef std::pair AuthProperty; - -class AuthPropertyIterator - : public std::iterator { - public: - ~AuthPropertyIterator(); - AuthPropertyIterator& operator++(); - AuthPropertyIterator operator++(int); - bool operator==(const AuthPropertyIterator& rhs) const; - bool operator!=(const AuthPropertyIterator& rhs) const; - const AuthProperty operator*(); - - protected: - AuthPropertyIterator(); - AuthPropertyIterator(const grpc_auth_property* property, - const grpc_auth_property_iterator* iter); - - private: - friend class SecureAuthContext; - const grpc_auth_property* property_; - // The following items form a grpc_auth_property_iterator. - const grpc_auth_context* ctx_; - size_t index_; - const char* name_; -}; - -class AuthContext { - public: - virtual ~AuthContext() {} - - // A peer identity, in general is one or more properties (in which case they - // have the same name). - virtual std::vector GetPeerIdentity() const = 0; - virtual grpc::string GetPeerIdentityPropertyName() const = 0; - - // Returns all the property values with the given name. - virtual std::vector FindPropertyValues( - const grpc::string& name) const = 0; - - // Iteration over all the properties. - virtual AuthPropertyIterator begin() const = 0; - virtual AuthPropertyIterator end() const = 0; -}; - -} // namespace grpc - -#endif // GRPCXX_AUTH_CONTEXT_H diff --git a/include/grpc++/byte_buffer.h b/include/grpc++/byte_buffer.h deleted file mode 100644 index 6467776398..0000000000 --- a/include/grpc++/byte_buffer.h +++ /dev/null @@ -1,104 +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 GRPCXX_BYTE_BUFFER_H -#define GRPCXX_BYTE_BUFFER_H - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace grpc { - -class ByteBuffer GRPC_FINAL { - public: - ByteBuffer() : buffer_(nullptr) {} - - ByteBuffer(const Slice* slices, size_t nslices); - - ~ByteBuffer() { - if (buffer_) { - grpc_byte_buffer_destroy(buffer_); - } - } - - void Dump(std::vector* slices) const; - - void Clear(); - size_t Length() const; - - private: - friend class SerializationTraits; - - ByteBuffer(const ByteBuffer&); - ByteBuffer& operator=(const ByteBuffer&); - - // takes ownership - void set_buffer(grpc_byte_buffer* buf) { - if (buffer_) { - gpr_log(GPR_ERROR, "Overriding existing buffer"); - Clear(); - } - buffer_ = buf; - } - - grpc_byte_buffer* buffer() const { return buffer_; } - - grpc_byte_buffer* buffer_; -}; - -template <> -class SerializationTraits { - public: - static Status Deserialize(grpc_byte_buffer* byte_buffer, ByteBuffer* dest, - int max_message_size) { - dest->set_buffer(byte_buffer); - return Status::OK; - } - static Status Serialize(const ByteBuffer& source, grpc_byte_buffer** buffer, - bool* own_buffer) { - *buffer = source.buffer(); - *own_buffer = false; - return Status::OK; - } -}; - -} // namespace grpc - -#endif // GRPCXX_BYTE_BUFFER_H diff --git a/include/grpc++/channel.h b/include/grpc++/channel.h index 7d6216e9c4..a8af74175b 100644 --- a/include/grpc++/channel.h +++ b/include/grpc++/channel.h @@ -37,9 +37,9 @@ #include #include -#include #include #include +#include struct grpc_channel; diff --git a/include/grpc++/channel_arguments.h b/include/grpc++/channel_arguments.h deleted file mode 100644 index 4d926377ec..0000000000 --- a/include/grpc++/channel_arguments.h +++ /dev/null @@ -1,93 +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 GRPCXX_CHANNEL_ARGUMENTS_H -#define GRPCXX_CHANNEL_ARGUMENTS_H - -#include -#include - -#include -#include -#include - -namespace grpc { -namespace testing { -class ChannelArgumentsTest; -} // namespace testing - -// Options for channel creation. The user can use generic setters to pass -// key value pairs down to c channel creation code. For grpc related options, -// concrete setters are provided. -class ChannelArguments { - public: - ChannelArguments() {} - ~ChannelArguments() {} - - ChannelArguments(const ChannelArguments& other); - ChannelArguments& operator=(ChannelArguments other) { - Swap(other); - return *this; - } - - void Swap(ChannelArguments& other); - - // grpc specific channel argument setters - // Set target name override for SSL host name checking. - void SetSslTargetNameOverride(const grpc::string& name); - // TODO(yangg) add flow control options - - // Set the compression algorithm for the channel. - void SetCompressionAlgorithm(grpc_compression_algorithm algorithm); - - // Generic channel argument setters. Only for advanced use cases. - void SetInt(const grpc::string& key, int value); - void SetString(const grpc::string& key, const grpc::string& value); - - // Populates given channel_args with args_, does not take ownership. - void SetChannelArgs(grpc_channel_args* channel_args) const; - - private: - friend class SecureCredentials; - friend class testing::ChannelArgumentsTest; - - // Returns empty string when it is not set. - grpc::string GetSslTargetNameOverride() const; - - std::vector args_; - std::list strings_; -}; - -} // namespace grpc - -#endif // GRPCXX_CHANNEL_ARGUMENTS_H diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h index 55ed17506a..ee28f360cb 100644 --- a/include/grpc++/client_context.h +++ b/include/grpc++/client_context.h @@ -42,10 +42,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include struct census_context; diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h index 061f4874fa..d81d2e735d 100644 --- a/include/grpc++/completion_queue.h +++ b/include/grpc++/completion_queue.h @@ -36,8 +36,8 @@ #include #include -#include -#include +#include +#include struct grpc_completion_queue; diff --git a/include/grpc++/config.h b/include/grpc++/config.h deleted file mode 100644 index 889dc39eb7..0000000000 --- a/include/grpc++/config.h +++ /dev/null @@ -1,116 +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 GRPCXX_CONFIG_H -#define GRPCXX_CONFIG_H - -#if !defined(GRPC_NO_AUTODETECT_PLATFORM) - -#ifdef _MSC_VER -// Visual Studio 2010 is 1600. -#if _MSC_VER < 1600 -#error "gRPC is only supported with Visual Studio starting at 2010" -// Visual Studio 2013 is 1800. -#elif _MSC_VER < 1800 -#define GRPC_CXX0X_NO_FINAL 1 -#define GRPC_CXX0X_NO_OVERRIDE 1 -#define GRPC_CXX0X_NO_CHRONO 1 -#define GRPC_CXX0X_NO_THREAD 1 -#endif -#endif // Visual Studio - -#ifndef __clang__ -#ifdef __GNUC__ -// nullptr was added in gcc 4.6 -#if (__GNUC__ * 100 + __GNUC_MINOR__ < 406) -#define GRPC_CXX0X_NO_NULLPTR 1 -#endif -// final and override were added in gcc 4.7 -#if (__GNUC__ * 100 + __GNUC_MINOR__ < 407) -#define GRPC_CXX0X_NO_FINAL 1 -#define GRPC_CXX0X_NO_OVERRIDE 1 -#endif -#endif -#endif - -#endif - -#ifdef GRPC_CXX0X_NO_FINAL -#define GRPC_FINAL -#else -#define GRPC_FINAL final -#endif - -#ifdef GRPC_CXX0X_NO_OVERRIDE -#define GRPC_OVERRIDE -#else -#define GRPC_OVERRIDE override -#endif - -#ifdef GRPC_CXX0X_NO_NULLPTR -#include -namespace grpc { -const class { - public: - template - operator T *() const { - return static_cast(0); - } - template - operator std::unique_ptr() const { - return std::unique_ptr(static_cast(0)); - } - template - operator std::shared_ptr() const { - return std::shared_ptr(static_cast(0)); - } - operator bool() const { return false; } - - private: - void operator&() const = delete; -} nullptr = {}; -} -#endif - -#ifndef GRPC_CUSTOM_STRING -#include -#define GRPC_CUSTOM_STRING std::string -#endif - -namespace grpc { - -typedef GRPC_CUSTOM_STRING string; - -} // namespace grpc - -#endif // GRPCXX_CONFIG_H diff --git a/include/grpc++/config_protobuf.h b/include/grpc++/config_protobuf.h deleted file mode 100644 index 3afc7a58e2..0000000000 --- a/include/grpc++/config_protobuf.h +++ /dev/null @@ -1,72 +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 GRPCXX_CONFIG_PROTOBUF_H -#define GRPCXX_CONFIG_PROTOBUF_H - -#ifndef GRPC_CUSTOM_PROTOBUF_INT64 -#include -#define GRPC_CUSTOM_PROTOBUF_INT64 ::google::protobuf::int64 -#endif - -#ifndef GRPC_CUSTOM_MESSAGE -#include -#define GRPC_CUSTOM_MESSAGE ::google::protobuf::Message -#endif - -#ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM -#include -#include -#define GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM \ - ::google::protobuf::io::ZeroCopyOutputStream -#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \ - ::google::protobuf::io::ZeroCopyInputStream -#define GRPC_CUSTOM_CODEDINPUTSTREAM ::google::protobuf::io::CodedInputStream -#endif - -namespace grpc { -namespace protobuf { - -typedef GRPC_CUSTOM_MESSAGE Message; -typedef GRPC_CUSTOM_PROTOBUF_INT64 int64; - -namespace io { -typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream; -typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream; -typedef GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream; -} // namespace io - -} // namespace protobuf -} // namespace grpc - -#endif // GRPCXX_CONFIG_PROTOBUF_H diff --git a/include/grpc++/create_channel.h b/include/grpc++/create_channel.h index fe34452128..0e559ac53e 100644 --- a/include/grpc++/create_channel.h +++ b/include/grpc++/create_channel.h @@ -36,11 +36,11 @@ #include -#include #include +#include +#include namespace grpc { -class ChannelArguments; // If creds does not hold an object or is invalid, a lame channel is returned. std::shared_ptr CreateChannel( diff --git a/include/grpc++/credentials.h b/include/grpc++/credentials.h index 306dc961c0..71e1f00f15 100644 --- a/include/grpc++/credentials.h +++ b/include/grpc++/credentials.h @@ -36,8 +36,8 @@ #include -#include #include +#include namespace grpc { class ChannelArguments; diff --git a/include/grpc++/dynamic_thread_pool.h b/include/grpc++/dynamic_thread_pool.h deleted file mode 100644 index a4d4885b51..0000000000 --- a/include/grpc++/dynamic_thread_pool.h +++ /dev/null @@ -1,83 +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 GRPCXX_DYNAMIC_THREAD_POOL_H -#define GRPCXX_DYNAMIC_THREAD_POOL_H - -#include - -#include -#include -#include - -#include -#include -#include - -namespace grpc { - -class DynamicThreadPool GRPC_FINAL : public ThreadPoolInterface { - public: - explicit DynamicThreadPool(int reserve_threads); - ~DynamicThreadPool(); - - void Add(const std::function& callback) GRPC_OVERRIDE; - - private: - class DynamicThread { - public: - DynamicThread(DynamicThreadPool* pool); - ~DynamicThread(); - - private: - DynamicThreadPool* pool_; - std::unique_ptr thd_; - void ThreadFunc(); - }; - grpc::mutex mu_; - grpc::condition_variable cv_; - grpc::condition_variable shutdown_cv_; - bool shutdown_; - std::queue> callbacks_; - int reserve_threads_; - int nthreads_; - int threads_waiting_; - std::list dead_threads_; - - void ThreadFunc(); - static void ReapThreads(std::list* tlist); -}; - -} // namespace grpc - -#endif // GRPCXX_DYNAMIC_THREAD_POOL_H diff --git a/include/grpc++/fixed_size_thread_pool.h b/include/grpc++/fixed_size_thread_pool.h deleted file mode 100644 index 307e166142..0000000000 --- a/include/grpc++/fixed_size_thread_pool.h +++ /dev/null @@ -1,67 +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 GRPCXX_FIXED_SIZE_THREAD_POOL_H -#define GRPCXX_FIXED_SIZE_THREAD_POOL_H - -#include - -#include -#include -#include - -#include -#include - -namespace grpc { - -class FixedSizeThreadPool GRPC_FINAL : public ThreadPoolInterface { - public: - explicit FixedSizeThreadPool(int num_threads); - ~FixedSizeThreadPool(); - - void Add(const std::function& callback) GRPC_OVERRIDE; - - private: - grpc::mutex mu_; - grpc::condition_variable cv_; - bool shutdown_; - std::queue> callbacks_; - std::vector threads_; - - void ThreadFunc(); -}; - -} // namespace grpc - -#endif // GRPCXX_FIXED_SIZE_THREAD_POOL_H diff --git a/include/grpc++/generic/async_generic_service.h b/include/grpc++/generic/async_generic_service.h new file mode 100644 index 0000000000..35bc945824 --- /dev/null +++ b/include/grpc++/generic/async_generic_service.h @@ -0,0 +1,78 @@ +/* + * + * 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 GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H +#define GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H + +#include +#include + +struct grpc_server; + +namespace grpc { + +typedef ServerAsyncReaderWriter + GenericServerAsyncReaderWriter; + +class GenericServerContext GRPC_FINAL : public ServerContext { + public: + const grpc::string& method() const { return method_; } + const grpc::string& host() const { return host_; } + + private: + friend class Server; + + grpc::string method_; + grpc::string host_; +}; + +class AsyncGenericService GRPC_FINAL { + public: + // TODO(yangg) Once we can add multiple completion queues to the server + // in c core, add a CompletionQueue* argument to the ctor here. + // TODO(yangg) support methods list. + AsyncGenericService(const grpc::string& methods) : server_(nullptr) {} + + void RequestCall(GenericServerContext* ctx, + GenericServerAsyncReaderWriter* reader_writer, + CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, void* tag); + + private: + friend class Server; + Server* server_; +}; + +} // namespace grpc + +#endif // GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H diff --git a/include/grpc++/generic/generic_stub.h b/include/grpc++/generic/generic_stub.h new file mode 100644 index 0000000000..08ed77aefb --- /dev/null +++ b/include/grpc++/generic/generic_stub.h @@ -0,0 +1,63 @@ +/* + * + * 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 GRPCXX_GENERIC_GENERIC_STUB_H +#define GRPCXX_GENERIC_GENERIC_STUB_H + +#include +#include + +namespace grpc { + +class CompletionQueue; +typedef ClientAsyncReaderWriter + GenericClientAsyncReaderWriter; + +// Generic stubs provide a type-unsafe interface to call gRPC methods +// by name. +class GenericStub GRPC_FINAL { + public: + explicit GenericStub(std::shared_ptr channel) : channel_(channel) {} + + // begin a call to a named method + std::unique_ptr Call( + ClientContext* context, const grpc::string& method, CompletionQueue* cq, + void* tag); + + private: + std::shared_ptr channel_; +}; + +} // namespace grpc + +#endif // GRPCXX_GENERIC_GENERIC_STUB_H diff --git a/include/grpc++/generic_stub.h b/include/grpc++/generic_stub.h deleted file mode 100644 index 734440881e..0000000000 --- a/include/grpc++/generic_stub.h +++ /dev/null @@ -1,63 +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 GRPCXX_GENERIC_STUB_H -#define GRPCXX_GENERIC_STUB_H - -#include -#include - -namespace grpc { - -class CompletionQueue; -typedef ClientAsyncReaderWriter - GenericClientAsyncReaderWriter; - -// Generic stubs provide a type-unsafe interface to call gRPC methods -// by name. -class GenericStub GRPC_FINAL { - public: - explicit GenericStub(std::shared_ptr channel) : channel_(channel) {} - - // begin a call to a named method - std::unique_ptr Call( - ClientContext* context, const grpc::string& method, CompletionQueue* cq, - void* tag); - - private: - std::shared_ptr channel_; -}; - -} // namespace grpc - -#endif // GRPCXX_GENERIC_STUB_H diff --git a/include/grpc++/impl/call.h b/include/grpc++/impl/call.h index bc1db4c12c..ed3110fdb7 100644 --- a/include/grpc++/impl/call.h +++ b/include/grpc++/impl/call.h @@ -34,18 +34,17 @@ #ifndef GRPCXX_IMPL_CALL_H #define GRPCXX_IMPL_CALL_H -#include -#include -#include -#include -#include -#include - #include #include #include +#include -#include +#include +#include +#include +#include +#include +#include struct grpc_call; struct grpc_op; diff --git a/include/grpc++/impl/client_unary_call.h b/include/grpc++/impl/client_unary_call.h index 4aae816cd7..4cdc800267 100644 --- a/include/grpc++/impl/client_unary_call.h +++ b/include/grpc++/impl/client_unary_call.h @@ -34,10 +34,9 @@ #ifndef GRPCXX_IMPL_CLIENT_UNARY_CALL_H #define GRPCXX_IMPL_CLIENT_UNARY_CALL_H -#include -#include - #include +#include +#include namespace grpc { diff --git a/include/grpc++/impl/proto_utils.h b/include/grpc++/impl/proto_utils.h index ebefa3e1be..283e33486d 100644 --- a/include/grpc++/impl/proto_utils.h +++ b/include/grpc++/impl/proto_utils.h @@ -38,8 +38,8 @@ #include #include -#include -#include +#include +#include namespace grpc { diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h index 078c8c491a..0138eb2ac0 100644 --- a/include/grpc++/impl/rpc_service_method.h +++ b/include/grpc++/impl/rpc_service_method.h @@ -39,10 +39,10 @@ #include #include -#include #include -#include -#include +#include +#include +#include namespace grpc { class ServerContext; diff --git a/include/grpc++/impl/service_type.h b/include/grpc++/impl/service_type.h index c33a278f5b..3b6ac1de77 100644 --- a/include/grpc++/impl/service_type.h +++ b/include/grpc++/impl/service_type.h @@ -34,10 +34,10 @@ #ifndef GRPCXX_IMPL_SERVICE_TYPE_H #define GRPCXX_IMPL_SERVICE_TYPE_H -#include #include #include -#include +#include +#include namespace grpc { diff --git a/include/grpc++/impl/sync.h b/include/grpc++/impl/sync.h index 2f41d2bdeb..999c4303cb 100644 --- a/include/grpc++/impl/sync.h +++ b/include/grpc++/impl/sync.h @@ -34,7 +34,7 @@ #ifndef GRPCXX_IMPL_SYNC_H #define GRPCXX_IMPL_SYNC_H -#include +#include #ifdef GRPC_CXX0X_NO_THREAD #include diff --git a/include/grpc++/impl/thd.h b/include/grpc++/impl/thd.h index 4c4578a92d..f8d4258ac6 100644 --- a/include/grpc++/impl/thd.h +++ b/include/grpc++/impl/thd.h @@ -34,7 +34,7 @@ #ifndef GRPCXX_IMPL_THD_H #define GRPCXX_IMPL_THD_H -#include +#include #ifdef GRPC_CXX0X_NO_THREAD #include diff --git a/include/grpc++/server.h b/include/grpc++/server.h index a2bc097c7f..183cbc4692 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -38,11 +38,11 @@ #include #include -#include #include #include #include -#include +#include +#include struct grpc_server; diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index 906daf1370..95325915a1 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -37,7 +37,7 @@ #include #include -#include +#include namespace grpc { diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h index b87a1f0379..ce3cb47a23 100644 --- a/include/grpc++/server_context.h +++ b/include/grpc++/server_context.h @@ -39,9 +39,9 @@ #include #include -#include -#include -#include +#include +#include +#include struct gpr_timespec; struct grpc_metadata; diff --git a/include/grpc++/server_credentials.h b/include/grpc++/server_credentials.h index 11acd67e8a..16b78c08af 100644 --- a/include/grpc++/server_credentials.h +++ b/include/grpc++/server_credentials.h @@ -37,7 +37,7 @@ #include #include -#include +#include struct grpc_server; diff --git a/include/grpc++/slice.h b/include/grpc++/slice.h deleted file mode 100644 index 3e01bcf0ad..0000000000 --- a/include/grpc++/slice.h +++ /dev/null @@ -1,74 +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 GRPCXX_SLICE_H -#define GRPCXX_SLICE_H - -#include -#include - -namespace grpc { - -class Slice GRPC_FINAL { - public: - // construct empty slice - Slice(); - // destructor - drops one ref - ~Slice(); - // construct slice from grpc slice, adding a ref - enum AddRef { ADD_REF }; - Slice(gpr_slice slice, AddRef); - // construct slice from grpc slice, stealing a ref - enum StealRef { STEAL_REF }; - Slice(gpr_slice slice, StealRef); - // copy constructor - adds a ref - Slice(const Slice& other); - // assignment - ref count is unchanged - Slice& operator=(Slice other) { - std::swap(slice_, other.slice_); - return *this; - } - - size_t size() const { return GPR_SLICE_LENGTH(slice_); } - const gpr_uint8* begin() const { return GPR_SLICE_START_PTR(slice_); } - const gpr_uint8* end() const { return GPR_SLICE_END_PTR(slice_); } - - private: - friend class ByteBuffer; - - gpr_slice slice_; -}; - -} // namespace grpc - -#endif // GRPCXX_SLICE_H diff --git a/include/grpc++/status.h b/include/grpc++/status.h deleted file mode 100644 index fb8526ddce..0000000000 --- a/include/grpc++/status.h +++ /dev/null @@ -1,64 +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 GRPCXX_STATUS_H -#define GRPCXX_STATUS_H - -#include -#include - -namespace grpc { - -class Status { - public: - Status() : code_(StatusCode::OK) {} - Status(StatusCode code, const grpc::string& details) - : code_(code), details_(details) {} - - // Pre-defined special status objects. - static const Status& OK; - static const Status& CANCELLED; - - StatusCode error_code() const { return code_; } - grpc::string error_message() const { return details_; } - - bool ok() const { return code_ == StatusCode::OK; } - - private: - StatusCode code_; - grpc::string details_; -}; - -} // namespace grpc - -#endif // GRPCXX_STATUS_H diff --git a/include/grpc++/status_code_enum.h b/include/grpc++/status_code_enum.h deleted file mode 100644 index 2211c964cd..0000000000 --- a/include/grpc++/status_code_enum.h +++ /dev/null @@ -1,159 +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 GRPCXX_STATUS_CODE_ENUM_H -#define GRPCXX_STATUS_CODE_ENUM_H - -namespace grpc { - -enum StatusCode { - /* Not an error; returned on success */ - OK = 0, - - /* The operation was cancelled (typically by the caller). */ - CANCELLED = 1, - - /* Unknown error. An example of where this error may be returned is - if a Status value received from another address space belongs to - an error-space that is not known in this address space. Also - errors raised by APIs that do not return enough error information - may be converted to this error. */ - UNKNOWN = 2, - - /* Client specified an invalid argument. Note that this differs - from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments - that are problematic regardless of the state of the system - (e.g., a malformed file name). */ - INVALID_ARGUMENT = 3, - - /* Deadline expired before operation could complete. For operations - that change the state of the system, this error may be returned - even if the operation has completed successfully. For example, a - successful response from a server could have been delayed long - enough for the deadline to expire. */ - DEADLINE_EXCEEDED = 4, - - /* Some requested entity (e.g., file or directory) was not found. */ - NOT_FOUND = 5, - - /* Some entity that we attempted to create (e.g., file or directory) - already exists. */ - ALREADY_EXISTS = 6, - - /* The caller does not have permission to execute the specified - operation. PERMISSION_DENIED must not be used for rejections - caused by exhausting some resource (use RESOURCE_EXHAUSTED - instead for those errors). PERMISSION_DENIED must not be - used if the caller can not be identified (use UNAUTHENTICATED - instead for those errors). */ - PERMISSION_DENIED = 7, - - /* The request does not have valid authentication credentials for the - operation. */ - UNAUTHENTICATED = 16, - - /* Some resource has been exhausted, perhaps a per-user quota, or - perhaps the entire file system is out of space. */ - RESOURCE_EXHAUSTED = 8, - - /* Operation was rejected because the system is not in a state - required for the operation's execution. For example, directory - to be deleted may be non-empty, an rmdir operation is applied to - a non-directory, etc. - - A litmus test that may help a service implementor in deciding - between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: - (a) Use UNAVAILABLE if the client can retry just the failing call. - (b) Use ABORTED if the client should retry at a higher-level - (e.g., restarting a read-modify-write sequence). - (c) Use FAILED_PRECONDITION if the client should not retry until - the system state has been explicitly fixed. E.g., if an "rmdir" - fails because the directory is non-empty, FAILED_PRECONDITION - should be returned since the client should not retry unless - they have first fixed up the directory by deleting files from it. - (d) Use FAILED_PRECONDITION if the client performs conditional - REST Get/Update/Delete on a resource and the resource on the - server does not match the condition. E.g., conflicting - read-modify-write on the same resource. */ - FAILED_PRECONDITION = 9, - - /* The operation was aborted, typically due to a concurrency issue - like sequencer check failures, transaction aborts, etc. - - See litmus test above for deciding between FAILED_PRECONDITION, - ABORTED, and UNAVAILABLE. */ - ABORTED = 10, - - /* Operation was attempted past the valid range. E.g., seeking or - reading past end of file. - - Unlike INVALID_ARGUMENT, this error indicates a problem that may - be fixed if the system state changes. For example, a 32-bit file - system will generate INVALID_ARGUMENT if asked to read at an - offset that is not in the range [0,2^32-1], but it will generate - OUT_OF_RANGE if asked to read from an offset past the current - file size. - - There is a fair bit of overlap between FAILED_PRECONDITION and - OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific - error) when it applies so that callers who are iterating through - a space can easily look for an OUT_OF_RANGE error to detect when - they are done. */ - OUT_OF_RANGE = 11, - - /* Operation is not implemented or not supported/enabled in this service. */ - UNIMPLEMENTED = 12, - - /* Internal errors. Means some invariants expected by underlying - system has been broken. If you see one of these errors, - something is very broken. */ - INTERNAL = 13, - - /* The service is currently unavailable. This is a most likely a - transient condition and may be corrected by retrying with - a backoff. - - See litmus test above for deciding between FAILED_PRECONDITION, - ABORTED, and UNAVAILABLE. */ - UNAVAILABLE = 14, - - /* Unrecoverable data loss or corruption. */ - DATA_LOSS = 15, - - /* Force users to include a default branch: */ - DO_NOT_USE = -1 -}; - -} // namespace grpc - -#endif // GRPCXX_STATUS_CODE_ENUM_H diff --git a/include/grpc++/stream.h b/include/grpc++/stream.h deleted file mode 100644 index 577eb4e925..0000000000 --- a/include/grpc++/stream.h +++ /dev/null @@ -1,776 +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 GRPCXX_STREAM_H -#define GRPCXX_STREAM_H - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace grpc { - -// Common interface for all client side streaming. -class ClientStreamingInterface { - public: - virtual ~ClientStreamingInterface() {} - - // Wait until the stream finishes, and return the final status. When the - // client side declares it has no more message to send, either implicitly or - // by calling WritesDone, it needs to make sure there is no more message to - // be received from the server, either implicitly or by getting a false from - // a Read(). - // This function will return either: - // - when all incoming messages have been read and the server has returned - // status - // - OR when the server has returned a non-OK status - virtual Status Finish() = 0; -}; - -// An interface that yields a sequence of R messages. -template -class ReaderInterface { - public: - virtual ~ReaderInterface() {} - - // Blocking read a message and parse to msg. Returns true on success. - // The method returns false when there will be no more incoming messages, - // either because the other side has called WritesDone or the stream has - // failed (or been cancelled). - virtual bool Read(R* msg) = 0; -}; - -// An interface that can be fed a sequence of W messages. -template -class WriterInterface { - public: - virtual ~WriterInterface() {} - - // Blocking write msg to the stream. Returns true on success. - // Returns false when the stream has been closed. - virtual bool Write(const W& msg, const WriteOptions& options) = 0; - - inline bool Write(const W& msg) { return Write(msg, WriteOptions()); } -}; - -template -class ClientReaderInterface : public ClientStreamingInterface, - public ReaderInterface { - public: - virtual void WaitForInitialMetadata() = 0; -}; - -template -class ClientReader GRPC_FINAL : public ClientReaderInterface { - public: - // Blocking create a stream and write the first request out. - template - ClientReader(Channel* channel, const RpcMethod& method, - ClientContext* context, const W& request) - : context_(context), call_(channel->CreateCall(method, context, &cq_)) { - CallOpSet ops; - ops.SendInitialMetadata(context->send_initial_metadata_); - // TODO(ctiller): don't assert - GPR_ASSERT(ops.SendMessage(request).ok()); - ops.ClientSendClose(); - call_.PerformOps(&ops); - cq_.Pluck(&ops); - } - - // Blocking wait for initial metadata from server. The received metadata - // can only be accessed after this call returns. Should only be called before - // the first read. Calling this method is optional, and if it is not called - // the metadata will be available in ClientContext after the first read. - void WaitForInitialMetadata() { - GPR_ASSERT(!context_->initial_metadata_received_); - - CallOpSet ops; - ops.RecvInitialMetadata(context_); - call_.PerformOps(&ops); - cq_.Pluck(&ops); // status ignored - } - - bool Read(R* msg) GRPC_OVERRIDE { - CallOpSet> ops; - if (!context_->initial_metadata_received_) { - ops.RecvInitialMetadata(context_); - } - ops.RecvMessage(msg); - call_.PerformOps(&ops); - return cq_.Pluck(&ops) && ops.got_message; - } - - Status Finish() GRPC_OVERRIDE { - CallOpSet ops; - Status status; - ops.ClientRecvStatus(context_, &status); - call_.PerformOps(&ops); - GPR_ASSERT(cq_.Pluck(&ops)); - return status; - } - - private: - ClientContext* context_; - CompletionQueue cq_; - Call call_; -}; - -template -class ClientWriterInterface : public ClientStreamingInterface, - public WriterInterface { - public: - virtual bool WritesDone() = 0; -}; - -template -class ClientWriter : public ClientWriterInterface { - public: - // Blocking create a stream. - template - ClientWriter(Channel* channel, const RpcMethod& method, - ClientContext* context, R* response) - : context_(context), call_(channel->CreateCall(method, context, &cq_)) { - finish_ops_.RecvMessage(response); - - CallOpSet ops; - ops.SendInitialMetadata(context->send_initial_metadata_); - call_.PerformOps(&ops); - cq_.Pluck(&ops); - } - - using WriterInterface::Write; - bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { - CallOpSet ops; - if (!ops.SendMessage(msg, options).ok()) { - return false; - } - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - bool WritesDone() GRPC_OVERRIDE { - CallOpSet ops; - ops.ClientSendClose(); - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - // Read the final response and wait for the final status. - Status Finish() GRPC_OVERRIDE { - Status status; - finish_ops_.ClientRecvStatus(context_, &status); - call_.PerformOps(&finish_ops_); - GPR_ASSERT(cq_.Pluck(&finish_ops_)); - return status; - } - - private: - ClientContext* context_; - CallOpSet finish_ops_; - CompletionQueue cq_; - Call call_; -}; - -// Client-side interface for bi-directional streaming. -template -class ClientReaderWriterInterface : public ClientStreamingInterface, - public WriterInterface, - public ReaderInterface { - public: - virtual void WaitForInitialMetadata() = 0; - virtual bool WritesDone() = 0; -}; - -template -class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { - public: - // Blocking create a stream. - ClientReaderWriter(Channel* channel, const RpcMethod& method, - ClientContext* context) - : context_(context), call_(channel->CreateCall(method, context, &cq_)) { - CallOpSet ops; - ops.SendInitialMetadata(context->send_initial_metadata_); - call_.PerformOps(&ops); - cq_.Pluck(&ops); - } - - // Blocking wait for initial metadata from server. The received metadata - // can only be accessed after this call returns. Should only be called before - // the first read. Calling this method is optional, and if it is not called - // the metadata will be available in ClientContext after the first read. - void WaitForInitialMetadata() { - GPR_ASSERT(!context_->initial_metadata_received_); - - CallOpSet ops; - ops.RecvInitialMetadata(context_); - call_.PerformOps(&ops); - cq_.Pluck(&ops); // status ignored - } - - bool Read(R* msg) GRPC_OVERRIDE { - CallOpSet> ops; - if (!context_->initial_metadata_received_) { - ops.RecvInitialMetadata(context_); - } - ops.RecvMessage(msg); - call_.PerformOps(&ops); - return cq_.Pluck(&ops) && ops.got_message; - } - - using WriterInterface::Write; - bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { - CallOpSet ops; - if (!ops.SendMessage(msg, options).ok()) return false; - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - bool WritesDone() GRPC_OVERRIDE { - CallOpSet ops; - ops.ClientSendClose(); - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - Status Finish() GRPC_OVERRIDE { - CallOpSet ops; - Status status; - ops.ClientRecvStatus(context_, &status); - call_.PerformOps(&ops); - GPR_ASSERT(cq_.Pluck(&ops)); - return status; - } - - private: - ClientContext* context_; - CompletionQueue cq_; - Call call_; -}; - -template -class ServerReader GRPC_FINAL : public ReaderInterface { - public: - ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} - - void SendInitialMetadata() { - GPR_ASSERT(!ctx_->sent_initial_metadata_); - - CallOpSet ops; - ops.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - call_->PerformOps(&ops); - call_->cq()->Pluck(&ops); - } - - bool Read(R* msg) GRPC_OVERRIDE { - CallOpSet> ops; - ops.RecvMessage(msg); - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops) && ops.got_message; - } - - private: - Call* const call_; - ServerContext* const ctx_; -}; - -template -class ServerWriter GRPC_FINAL : public WriterInterface { - public: - ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} - - void SendInitialMetadata() { - GPR_ASSERT(!ctx_->sent_initial_metadata_); - - CallOpSet ops; - ops.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - call_->PerformOps(&ops); - call_->cq()->Pluck(&ops); - } - - using WriterInterface::Write; - bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { - CallOpSet ops; - if (!ops.SendMessage(msg, options).ok()) { - return false; - } - if (!ctx_->sent_initial_metadata_) { - ops.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops); - } - - private: - Call* const call_; - ServerContext* const ctx_; -}; - -// Server-side interface for bi-directional streaming. -template -class ServerReaderWriter GRPC_FINAL : public WriterInterface, - public ReaderInterface { - public: - ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} - - void SendInitialMetadata() { - GPR_ASSERT(!ctx_->sent_initial_metadata_); - - CallOpSet ops; - ops.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - call_->PerformOps(&ops); - call_->cq()->Pluck(&ops); - } - - bool Read(R* msg) GRPC_OVERRIDE { - CallOpSet> ops; - ops.RecvMessage(msg); - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops) && ops.got_message; - } - - using WriterInterface::Write; - bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { - CallOpSet ops; - if (!ops.SendMessage(msg, options).ok()) { - return false; - } - if (!ctx_->sent_initial_metadata_) { - ops.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops); - } - - private: - Call* const call_; - ServerContext* const ctx_; -}; - -// Async interfaces -// Common interface for all client side streaming. -class ClientAsyncStreamingInterface { - public: - virtual ~ClientAsyncStreamingInterface() {} - - virtual void ReadInitialMetadata(void* tag) = 0; - - virtual void Finish(Status* status, void* tag) = 0; -}; - -// An interface that yields a sequence of R messages. -template -class AsyncReaderInterface { - public: - virtual ~AsyncReaderInterface() {} - - virtual void Read(R* msg, void* tag) = 0; -}; - -// An interface that can be fed a sequence of W messages. -template -class AsyncWriterInterface { - public: - virtual ~AsyncWriterInterface() {} - - virtual void Write(const W& msg, void* tag) = 0; -}; - -template -class ClientAsyncReaderInterface : public ClientAsyncStreamingInterface, - public AsyncReaderInterface {}; - -template -class ClientAsyncReader GRPC_FINAL : public ClientAsyncReaderInterface { - public: - // Create a stream and write the first request out. - template - ClientAsyncReader(Channel* channel, CompletionQueue* cq, - const RpcMethod& method, ClientContext* context, - const W& request, void* tag) - : context_(context), call_(channel->CreateCall(method, context, cq)) { - init_ops_.set_output_tag(tag); - init_ops_.SendInitialMetadata(context->send_initial_metadata_); - // TODO(ctiller): don't assert - GPR_ASSERT(init_ops_.SendMessage(request).ok()); - init_ops_.ClientSendClose(); - call_.PerformOps(&init_ops_); - } - - void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) GRPC_OVERRIDE { - read_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - read_ops_.RecvInitialMetadata(context_); - } - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - void Finish(Status* status, void* tag) GRPC_OVERRIDE { - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - ClientContext* context_; - Call call_; - CallOpSet - init_ops_; - CallOpSet meta_ops_; - CallOpSet> read_ops_; - CallOpSet finish_ops_; -}; - -template -class ClientAsyncWriterInterface : public ClientAsyncStreamingInterface, - public AsyncWriterInterface { - public: - virtual void WritesDone(void* tag) = 0; -}; - -template -class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface { - public: - template - ClientAsyncWriter(Channel* channel, CompletionQueue* cq, - const RpcMethod& method, ClientContext* context, - R* response, void* tag) - : context_(context), call_(channel->CreateCall(method, context, cq)) { - finish_ops_.RecvMessage(response); - - init_ops_.set_output_tag(tag); - init_ops_.SendInitialMetadata(context->send_initial_metadata_); - call_.PerformOps(&init_ops_); - } - - void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Write(const W& msg, void* tag) GRPC_OVERRIDE { - write_ops_.set_output_tag(tag); - // TODO(ctiller): don't assert - GPR_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void WritesDone(void* tag) GRPC_OVERRIDE { - writes_done_ops_.set_output_tag(tag); - writes_done_ops_.ClientSendClose(); - call_.PerformOps(&writes_done_ops_); - } - - void Finish(Status* status, void* tag) GRPC_OVERRIDE { - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - ClientContext* context_; - Call call_; - CallOpSet init_ops_; - CallOpSet meta_ops_; - CallOpSet write_ops_; - CallOpSet writes_done_ops_; - CallOpSet finish_ops_; -}; - -// Client-side interface for bi-directional streaming. -template -class ClientAsyncReaderWriterInterface : public ClientAsyncStreamingInterface, - public AsyncWriterInterface, - public AsyncReaderInterface { - public: - virtual void WritesDone(void* tag) = 0; -}; - -template -class ClientAsyncReaderWriter GRPC_FINAL - : public ClientAsyncReaderWriterInterface { - public: - ClientAsyncReaderWriter(Channel* channel, CompletionQueue* cq, - const RpcMethod& method, ClientContext* context, - void* tag) - : context_(context), call_(channel->CreateCall(method, context, cq)) { - init_ops_.set_output_tag(tag); - init_ops_.SendInitialMetadata(context->send_initial_metadata_); - call_.PerformOps(&init_ops_); - } - - void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) GRPC_OVERRIDE { - read_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - read_ops_.RecvInitialMetadata(context_); - } - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - void Write(const W& msg, void* tag) GRPC_OVERRIDE { - write_ops_.set_output_tag(tag); - // TODO(ctiller): don't assert - GPR_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void WritesDone(void* tag) GRPC_OVERRIDE { - writes_done_ops_.set_output_tag(tag); - writes_done_ops_.ClientSendClose(); - call_.PerformOps(&writes_done_ops_); - } - - void Finish(Status* status, void* tag) GRPC_OVERRIDE { - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - ClientContext* context_; - Call call_; - CallOpSet init_ops_; - CallOpSet meta_ops_; - CallOpSet> read_ops_; - CallOpSet write_ops_; - CallOpSet writes_done_ops_; - CallOpSet finish_ops_; -}; - -template -class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncReaderInterface { - public: - explicit ServerAsyncReader(ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - void SendInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!ctx_->sent_initial_metadata_); - - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) GRPC_OVERRIDE { - read_ops_.set_output_tag(tag); - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - void Finish(const W& msg, const Status& status, void* tag) { - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (status.ok()) { - finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, - finish_ops_.SendMessage(msg)); - } else { - finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); - } - call_.PerformOps(&finish_ops_); - } - - void FinishWithError(const Status& status, void* tag) { - GPR_ASSERT(!status.ok()); - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } - - Call call_; - ServerContext* ctx_; - CallOpSet meta_ops_; - CallOpSet> read_ops_; - CallOpSet finish_ops_; -}; - -template -class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncWriterInterface { - public: - explicit ServerAsyncWriter(ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - void SendInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!ctx_->sent_initial_metadata_); - - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } - - void Write(const W& msg, void* tag) GRPC_OVERRIDE { - write_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - write_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - // TODO(ctiller): don't assert - GPR_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void Finish(const Status& status, void* tag) { - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } - - Call call_; - ServerContext* ctx_; - CallOpSet meta_ops_; - CallOpSet write_ops_; - CallOpSet finish_ops_; -}; - -// Server-side interface for bi-directional streaming. -template -class ServerAsyncReaderWriter GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncWriterInterface, - public AsyncReaderInterface { - public: - explicit ServerAsyncReaderWriter(ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - void SendInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!ctx_->sent_initial_metadata_); - - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) GRPC_OVERRIDE { - read_ops_.set_output_tag(tag); - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - void Write(const W& msg, void* tag) GRPC_OVERRIDE { - write_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - write_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - // TODO(ctiller): don't assert - GPR_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void Finish(const Status& status, void* tag) { - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } - - Call call_; - ServerContext* ctx_; - CallOpSet meta_ops_; - CallOpSet> read_ops_; - CallOpSet write_ops_; - CallOpSet finish_ops_; -}; - -} // namespace grpc - -#endif // GRPCXX_STREAM_H diff --git a/include/grpc++/stub_options.h b/include/grpc++/stub_options.h deleted file mode 100644 index c7c16dcd55..0000000000 --- a/include/grpc++/stub_options.h +++ /dev/null @@ -1,43 +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 GRPCXX_STUB_OPTIONS_H -#define GRPCXX_STUB_OPTIONS_H - -namespace grpc { - -class StubOptions {}; - -} // namespace grpc - -#endif // GRPCXX_STUB_OPTIONS_H diff --git a/include/grpc++/support/async_unary_call.h b/include/grpc++/support/async_unary_call.h new file mode 100644 index 0000000000..0f4ad2656f --- /dev/null +++ b/include/grpc++/support/async_unary_call.h @@ -0,0 +1,155 @@ +/* + * + * 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 GRPCXX_SUPPORT_ASYNC_UNARY_CALL_H +#define GRPCXX_SUPPORT_ASYNC_UNARY_CALL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpc { + +template +class ClientAsyncResponseReaderInterface { + public: + virtual ~ClientAsyncResponseReaderInterface() {} + virtual void ReadInitialMetadata(void* tag) = 0; + virtual void Finish(R* msg, Status* status, void* tag) = 0; +}; + +template +class ClientAsyncResponseReader GRPC_FINAL + : public ClientAsyncResponseReaderInterface { + public: + template + ClientAsyncResponseReader(Channel* channel, CompletionQueue* cq, + const RpcMethod& method, ClientContext* context, + const W& request) + : context_(context), call_(channel->CreateCall(method, context, cq)) { + init_buf_.SendInitialMetadata(context->send_initial_metadata_); + // TODO(ctiller): don't assert + GPR_ASSERT(init_buf_.SendMessage(request).ok()); + init_buf_.ClientSendClose(); + call_.PerformOps(&init_buf_); + } + + void ReadInitialMetadata(void* tag) { + GPR_ASSERT(!context_->initial_metadata_received_); + + meta_buf_.set_output_tag(tag); + meta_buf_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_buf_); + } + + void Finish(R* msg, Status* status, void* tag) { + finish_buf_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_buf_.RecvInitialMetadata(context_); + } + finish_buf_.RecvMessage(msg); + finish_buf_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_buf_); + } + + private: + ClientContext* context_; + Call call_; + SneakyCallOpSet init_buf_; + CallOpSet meta_buf_; + CallOpSet, + CallOpClientRecvStatus> finish_buf_; +}; + +template +class ServerAsyncResponseWriter GRPC_FINAL + : public ServerAsyncStreamingInterface { + public: + explicit ServerAsyncResponseWriter(ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + void SendInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!ctx_->sent_initial_metadata_); + + meta_buf_.set_output_tag(tag); + meta_buf_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_buf_); + } + + void Finish(const W& msg, const Status& status, void* tag) { + finish_buf_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_buf_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (status.ok()) { + finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, + finish_buf_.SendMessage(msg)); + } else { + finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, status); + } + call_.PerformOps(&finish_buf_); + } + + void FinishWithError(const Status& status, void* tag) { + GPR_ASSERT(!status.ok()); + finish_buf_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_buf_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_buf_); + } + + private: + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } + + Call call_; + ServerContext* ctx_; + CallOpSet meta_buf_; + CallOpSet finish_buf_; +}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_ASYNC_UNARY_CALL_H diff --git a/include/grpc++/support/auth_context.h b/include/grpc++/support/auth_context.h new file mode 100644 index 0000000000..f4f2dcf5bb --- /dev/null +++ b/include/grpc++/support/auth_context.h @@ -0,0 +1,95 @@ +/* + * + * 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 GRPCXX_SUPPORT_AUTH_CONTEXT_H +#define GRPCXX_SUPPORT_AUTH_CONTEXT_H + +#include +#include + +#include + +struct grpc_auth_context; +struct grpc_auth_property; +struct grpc_auth_property_iterator; + +namespace grpc { +class SecureAuthContext; + +typedef std::pair AuthProperty; + +class AuthPropertyIterator + : public std::iterator { + public: + ~AuthPropertyIterator(); + AuthPropertyIterator& operator++(); + AuthPropertyIterator operator++(int); + bool operator==(const AuthPropertyIterator& rhs) const; + bool operator!=(const AuthPropertyIterator& rhs) const; + const AuthProperty operator*(); + + protected: + AuthPropertyIterator(); + AuthPropertyIterator(const grpc_auth_property* property, + const grpc_auth_property_iterator* iter); + + private: + friend class SecureAuthContext; + const grpc_auth_property* property_; + // The following items form a grpc_auth_property_iterator. + const grpc_auth_context* ctx_; + size_t index_; + const char* name_; +}; + +class AuthContext { + public: + virtual ~AuthContext() {} + + // A peer identity, in general is one or more properties (in which case they + // have the same name). + virtual std::vector GetPeerIdentity() const = 0; + virtual grpc::string GetPeerIdentityPropertyName() const = 0; + + // Returns all the property values with the given name. + virtual std::vector FindPropertyValues( + const grpc::string& name) const = 0; + + // Iteration over all the properties. + virtual AuthPropertyIterator begin() const = 0; + virtual AuthPropertyIterator end() const = 0; +}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_AUTH_CONTEXT_H diff --git a/include/grpc++/support/byte_buffer.h b/include/grpc++/support/byte_buffer.h new file mode 100644 index 0000000000..3f8cc25f47 --- /dev/null +++ b/include/grpc++/support/byte_buffer.h @@ -0,0 +1,104 @@ +/* + * + * 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 GRPCXX_SUPPORT_BYTE_BUFFER_H +#define GRPCXX_SUPPORT_BYTE_BUFFER_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace grpc { + +class ByteBuffer GRPC_FINAL { + public: + ByteBuffer() : buffer_(nullptr) {} + + ByteBuffer(const Slice* slices, size_t nslices); + + ~ByteBuffer() { + if (buffer_) { + grpc_byte_buffer_destroy(buffer_); + } + } + + void Dump(std::vector* slices) const; + + void Clear(); + size_t Length() const; + + private: + friend class SerializationTraits; + + ByteBuffer(const ByteBuffer&); + ByteBuffer& operator=(const ByteBuffer&); + + // takes ownership + void set_buffer(grpc_byte_buffer* buf) { + if (buffer_) { + gpr_log(GPR_ERROR, "Overriding existing buffer"); + Clear(); + } + buffer_ = buf; + } + + grpc_byte_buffer* buffer() const { return buffer_; } + + grpc_byte_buffer* buffer_; +}; + +template <> +class SerializationTraits { + public: + static Status Deserialize(grpc_byte_buffer* byte_buffer, ByteBuffer* dest, + int max_message_size) { + dest->set_buffer(byte_buffer); + return Status::OK; + } + static Status Serialize(const ByteBuffer& source, grpc_byte_buffer** buffer, + bool* own_buffer) { + *buffer = source.buffer(); + *own_buffer = false; + return Status::OK; + } +}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_BYTE_BUFFER_H diff --git a/include/grpc++/support/channel_arguments.h b/include/grpc++/support/channel_arguments.h new file mode 100644 index 0000000000..cee68467c7 --- /dev/null +++ b/include/grpc++/support/channel_arguments.h @@ -0,0 +1,93 @@ +/* + * + * 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 GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H +#define GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H + +#include +#include + +#include +#include +#include + +namespace grpc { +namespace testing { +class ChannelArgumentsTest; +} // namespace testing + +// Options for channel creation. The user can use generic setters to pass +// key value pairs down to c channel creation code. For grpc related options, +// concrete setters are provided. +class ChannelArguments { + public: + ChannelArguments() {} + ~ChannelArguments() {} + + ChannelArguments(const ChannelArguments& other); + ChannelArguments& operator=(ChannelArguments other) { + Swap(other); + return *this; + } + + void Swap(ChannelArguments& other); + + // grpc specific channel argument setters + // Set target name override for SSL host name checking. + void SetSslTargetNameOverride(const grpc::string& name); + // TODO(yangg) add flow control options + + // Set the compression algorithm for the channel. + void SetCompressionAlgorithm(grpc_compression_algorithm algorithm); + + // Generic channel argument setters. Only for advanced use cases. + void SetInt(const grpc::string& key, int value); + void SetString(const grpc::string& key, const grpc::string& value); + + // Populates given channel_args with args_, does not take ownership. + void SetChannelArgs(grpc_channel_args* channel_args) const; + + private: + friend class SecureCredentials; + friend class testing::ChannelArgumentsTest; + + // Returns empty string when it is not set. + grpc::string GetSslTargetNameOverride() const; + + std::vector args_; + std::list strings_; +}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H diff --git a/include/grpc++/support/config.h b/include/grpc++/support/config.h new file mode 100644 index 0000000000..836bd47283 --- /dev/null +++ b/include/grpc++/support/config.h @@ -0,0 +1,116 @@ +/* + * + * 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 GRPCXX_SUPPORT_CONFIG_H +#define GRPCXX_SUPPORT_CONFIG_H + +#if !defined(GRPC_NO_AUTODETECT_PLATFORM) + +#ifdef _MSC_VER +// Visual Studio 2010 is 1600. +#if _MSC_VER < 1600 +#error "gRPC is only supported with Visual Studio starting at 2010" +// Visual Studio 2013 is 1800. +#elif _MSC_VER < 1800 +#define GRPC_CXX0X_NO_FINAL 1 +#define GRPC_CXX0X_NO_OVERRIDE 1 +#define GRPC_CXX0X_NO_CHRONO 1 +#define GRPC_CXX0X_NO_THREAD 1 +#endif +#endif // Visual Studio + +#ifndef __clang__ +#ifdef __GNUC__ +// nullptr was added in gcc 4.6 +#if (__GNUC__ * 100 + __GNUC_MINOR__ < 406) +#define GRPC_CXX0X_NO_NULLPTR 1 +#endif +// final and override were added in gcc 4.7 +#if (__GNUC__ * 100 + __GNUC_MINOR__ < 407) +#define GRPC_CXX0X_NO_FINAL 1 +#define GRPC_CXX0X_NO_OVERRIDE 1 +#endif +#endif +#endif + +#endif + +#ifdef GRPC_CXX0X_NO_FINAL +#define GRPC_FINAL +#else +#define GRPC_FINAL final +#endif + +#ifdef GRPC_CXX0X_NO_OVERRIDE +#define GRPC_OVERRIDE +#else +#define GRPC_OVERRIDE override +#endif + +#ifdef GRPC_CXX0X_NO_NULLPTR +#include +namespace grpc { +const class { + public: + template + operator T *() const { + return static_cast(0); + } + template + operator std::unique_ptr() const { + return std::unique_ptr(static_cast(0)); + } + template + operator std::shared_ptr() const { + return std::shared_ptr(static_cast(0)); + } + operator bool() const { return false; } + + private: + void operator&() const = delete; +} nullptr = {}; +} +#endif + +#ifndef GRPC_CUSTOM_STRING +#include +#define GRPC_CUSTOM_STRING std::string +#endif + +namespace grpc { + +typedef GRPC_CUSTOM_STRING string; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_CONFIG_H diff --git a/include/grpc++/support/config_protobuf.h b/include/grpc++/support/config_protobuf.h new file mode 100644 index 0000000000..8235590d41 --- /dev/null +++ b/include/grpc++/support/config_protobuf.h @@ -0,0 +1,72 @@ +/* + * + * 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 GRPCXX_SUPPORT_CONFIG_PROTOBUF_H +#define GRPCXX_SUPPORT_CONFIG_PROTOBUF_H + +#ifndef GRPC_CUSTOM_PROTOBUF_INT64 +#include +#define GRPC_CUSTOM_PROTOBUF_INT64 ::google::protobuf::int64 +#endif + +#ifndef GRPC_CUSTOM_MESSAGE +#include +#define GRPC_CUSTOM_MESSAGE ::google::protobuf::Message +#endif + +#ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM +#include +#include +#define GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM \ + ::google::protobuf::io::ZeroCopyOutputStream +#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \ + ::google::protobuf::io::ZeroCopyInputStream +#define GRPC_CUSTOM_CODEDINPUTSTREAM ::google::protobuf::io::CodedInputStream +#endif + +namespace grpc { +namespace protobuf { + +typedef GRPC_CUSTOM_MESSAGE Message; +typedef GRPC_CUSTOM_PROTOBUF_INT64 int64; + +namespace io { +typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream; +typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream; +typedef GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream; +} // namespace io + +} // namespace protobuf +} // namespace grpc + +#endif // GRPCXX_SUPPORT_CONFIG_PROTOBUF_H diff --git a/include/grpc++/support/dynamic_thread_pool.h b/include/grpc++/support/dynamic_thread_pool.h new file mode 100644 index 0000000000..6062705129 --- /dev/null +++ b/include/grpc++/support/dynamic_thread_pool.h @@ -0,0 +1,82 @@ +/* + * + * 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 GRPCXX_SUPPORT_DYNAMIC_THREAD_POOL_H +#define GRPCXX_SUPPORT_DYNAMIC_THREAD_POOL_H + +#include +#include +#include + +#include +#include +#include +#include + +namespace grpc { + +class DynamicThreadPool GRPC_FINAL : public ThreadPoolInterface { + public: + explicit DynamicThreadPool(int reserve_threads); + ~DynamicThreadPool(); + + void Add(const std::function& callback) GRPC_OVERRIDE; + + private: + class DynamicThread { + public: + DynamicThread(DynamicThreadPool* pool); + ~DynamicThread(); + + private: + DynamicThreadPool* pool_; + std::unique_ptr thd_; + void ThreadFunc(); + }; + grpc::mutex mu_; + grpc::condition_variable cv_; + grpc::condition_variable shutdown_cv_; + bool shutdown_; + std::queue> callbacks_; + int reserve_threads_; + int nthreads_; + int threads_waiting_; + std::list dead_threads_; + + void ThreadFunc(); + static void ReapThreads(std::list* tlist); +}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_DYNAMIC_THREAD_POOL_H diff --git a/include/grpc++/support/fixed_size_thread_pool.h b/include/grpc++/support/fixed_size_thread_pool.h new file mode 100644 index 0000000000..46ed745eff --- /dev/null +++ b/include/grpc++/support/fixed_size_thread_pool.h @@ -0,0 +1,66 @@ +/* + * + * 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 GRPCXX_SUPPORT_FIXED_SIZE_THREAD_POOL_H +#define GRPCXX_SUPPORT_FIXED_SIZE_THREAD_POOL_H + +#include +#include + +#include +#include +#include +#include + +namespace grpc { + +class FixedSizeThreadPool GRPC_FINAL : public ThreadPoolInterface { + public: + explicit FixedSizeThreadPool(int num_threads); + ~FixedSizeThreadPool(); + + void Add(const std::function& callback) GRPC_OVERRIDE; + + private: + grpc::mutex mu_; + grpc::condition_variable cv_; + bool shutdown_; + std::queue> callbacks_; + std::vector threads_; + + void ThreadFunc(); +}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_FIXED_SIZE_THREAD_POOL_H diff --git a/include/grpc++/support/slice.h b/include/grpc++/support/slice.h new file mode 100644 index 0000000000..b2343a7f3d --- /dev/null +++ b/include/grpc++/support/slice.h @@ -0,0 +1,74 @@ +/* + * + * 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 GRPCXX_SUPPORT_SLICE_H +#define GRPCXX_SUPPORT_SLICE_H + +#include +#include + +namespace grpc { + +class Slice GRPC_FINAL { + public: + // construct empty slice + Slice(); + // destructor - drops one ref + ~Slice(); + // construct slice from grpc slice, adding a ref + enum AddRef { ADD_REF }; + Slice(gpr_slice slice, AddRef); + // construct slice from grpc slice, stealing a ref + enum StealRef { STEAL_REF }; + Slice(gpr_slice slice, StealRef); + // copy constructor - adds a ref + Slice(const Slice& other); + // assignment - ref count is unchanged + Slice& operator=(Slice other) { + std::swap(slice_, other.slice_); + return *this; + } + + size_t size() const { return GPR_SLICE_LENGTH(slice_); } + const gpr_uint8* begin() const { return GPR_SLICE_START_PTR(slice_); } + const gpr_uint8* end() const { return GPR_SLICE_END_PTR(slice_); } + + private: + friend class ByteBuffer; + + gpr_slice slice_; +}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_SLICE_H diff --git a/include/grpc++/support/status.h b/include/grpc++/support/status.h new file mode 100644 index 0000000000..05750ff600 --- /dev/null +++ b/include/grpc++/support/status.h @@ -0,0 +1,64 @@ +/* + * + * 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 GRPCXX_SUPPORT_STATUS_H +#define GRPCXX_SUPPORT_STATUS_H + +#include +#include + +namespace grpc { + +class Status { + public: + Status() : code_(StatusCode::OK) {} + Status(StatusCode code, const grpc::string& details) + : code_(code), details_(details) {} + + // Pre-defined special status objects. + static const Status& OK; + static const Status& CANCELLED; + + StatusCode error_code() const { return code_; } + grpc::string error_message() const { return details_; } + + bool ok() const { return code_ == StatusCode::OK; } + + private: + StatusCode code_; + grpc::string details_; +}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_STATUS_H diff --git a/include/grpc++/support/status_code_enum.h b/include/grpc++/support/status_code_enum.h new file mode 100644 index 0000000000..7cb40452c8 --- /dev/null +++ b/include/grpc++/support/status_code_enum.h @@ -0,0 +1,159 @@ +/* + * + * 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 GRPCXX_SUPPORT_STATUS_CODE_ENUM_H +#define GRPCXX_SUPPORT_STATUS_CODE_ENUM_H + +namespace grpc { + +enum StatusCode { + /* Not an error; returned on success */ + OK = 0, + + /* The operation was cancelled (typically by the caller). */ + CANCELLED = 1, + + /* Unknown error. An example of where this error may be returned is + if a Status value received from another address space belongs to + an error-space that is not known in this address space. Also + errors raised by APIs that do not return enough error information + may be converted to this error. */ + UNKNOWN = 2, + + /* Client specified an invalid argument. Note that this differs + from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments + that are problematic regardless of the state of the system + (e.g., a malformed file name). */ + INVALID_ARGUMENT = 3, + + /* Deadline expired before operation could complete. For operations + that change the state of the system, this error may be returned + even if the operation has completed successfully. For example, a + successful response from a server could have been delayed long + enough for the deadline to expire. */ + DEADLINE_EXCEEDED = 4, + + /* Some requested entity (e.g., file or directory) was not found. */ + NOT_FOUND = 5, + + /* Some entity that we attempted to create (e.g., file or directory) + already exists. */ + ALREADY_EXISTS = 6, + + /* The caller does not have permission to execute the specified + operation. PERMISSION_DENIED must not be used for rejections + caused by exhausting some resource (use RESOURCE_EXHAUSTED + instead for those errors). PERMISSION_DENIED must not be + used if the caller can not be identified (use UNAUTHENTICATED + instead for those errors). */ + PERMISSION_DENIED = 7, + + /* The request does not have valid authentication credentials for the + operation. */ + UNAUTHENTICATED = 16, + + /* Some resource has been exhausted, perhaps a per-user quota, or + perhaps the entire file system is out of space. */ + RESOURCE_EXHAUSTED = 8, + + /* Operation was rejected because the system is not in a state + required for the operation's execution. For example, directory + to be deleted may be non-empty, an rmdir operation is applied to + a non-directory, etc. + + A litmus test that may help a service implementor in deciding + between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: + (a) Use UNAVAILABLE if the client can retry just the failing call. + (b) Use ABORTED if the client should retry at a higher-level + (e.g., restarting a read-modify-write sequence). + (c) Use FAILED_PRECONDITION if the client should not retry until + the system state has been explicitly fixed. E.g., if an "rmdir" + fails because the directory is non-empty, FAILED_PRECONDITION + should be returned since the client should not retry unless + they have first fixed up the directory by deleting files from it. + (d) Use FAILED_PRECONDITION if the client performs conditional + REST Get/Update/Delete on a resource and the resource on the + server does not match the condition. E.g., conflicting + read-modify-write on the same resource. */ + FAILED_PRECONDITION = 9, + + /* The operation was aborted, typically due to a concurrency issue + like sequencer check failures, transaction aborts, etc. + + See litmus test above for deciding between FAILED_PRECONDITION, + ABORTED, and UNAVAILABLE. */ + ABORTED = 10, + + /* Operation was attempted past the valid range. E.g., seeking or + reading past end of file. + + Unlike INVALID_ARGUMENT, this error indicates a problem that may + be fixed if the system state changes. For example, a 32-bit file + system will generate INVALID_ARGUMENT if asked to read at an + offset that is not in the range [0,2^32-1], but it will generate + OUT_OF_RANGE if asked to read from an offset past the current + file size. + + There is a fair bit of overlap between FAILED_PRECONDITION and + OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific + error) when it applies so that callers who are iterating through + a space can easily look for an OUT_OF_RANGE error to detect when + they are done. */ + OUT_OF_RANGE = 11, + + /* Operation is not implemented or not supported/enabled in this service. */ + UNIMPLEMENTED = 12, + + /* Internal errors. Means some invariants expected by underlying + system has been broken. If you see one of these errors, + something is very broken. */ + INTERNAL = 13, + + /* The service is currently unavailable. This is a most likely a + transient condition and may be corrected by retrying with + a backoff. + + See litmus test above for deciding between FAILED_PRECONDITION, + ABORTED, and UNAVAILABLE. */ + UNAVAILABLE = 14, + + /* Unrecoverable data loss or corruption. */ + DATA_LOSS = 15, + + /* Force users to include a default branch: */ + DO_NOT_USE = -1 +}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_STATUS_CODE_ENUM_H diff --git a/include/grpc++/support/stream.h b/include/grpc++/support/stream.h new file mode 100644 index 0000000000..89a6dd693d --- /dev/null +++ b/include/grpc++/support/stream.h @@ -0,0 +1,776 @@ +/* + * + * 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 GRPCXX_SUPPORT_STREAM_H +#define GRPCXX_SUPPORT_STREAM_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpc { + +// Common interface for all client side streaming. +class ClientStreamingInterface { + public: + virtual ~ClientStreamingInterface() {} + + // Wait until the stream finishes, and return the final status. When the + // client side declares it has no more message to send, either implicitly or + // by calling WritesDone, it needs to make sure there is no more message to + // be received from the server, either implicitly or by getting a false from + // a Read(). + // This function will return either: + // - when all incoming messages have been read and the server has returned + // status + // - OR when the server has returned a non-OK status + virtual Status Finish() = 0; +}; + +// An interface that yields a sequence of R messages. +template +class ReaderInterface { + public: + virtual ~ReaderInterface() {} + + // Blocking read a message and parse to msg. Returns true on success. + // The method returns false when there will be no more incoming messages, + // either because the other side has called WritesDone or the stream has + // failed (or been cancelled). + virtual bool Read(R* msg) = 0; +}; + +// An interface that can be fed a sequence of W messages. +template +class WriterInterface { + public: + virtual ~WriterInterface() {} + + // Blocking write msg to the stream. Returns true on success. + // Returns false when the stream has been closed. + virtual bool Write(const W& msg, const WriteOptions& options) = 0; + + inline bool Write(const W& msg) { return Write(msg, WriteOptions()); } +}; + +template +class ClientReaderInterface : public ClientStreamingInterface, + public ReaderInterface { + public: + virtual void WaitForInitialMetadata() = 0; +}; + +template +class ClientReader GRPC_FINAL : public ClientReaderInterface { + public: + // Blocking create a stream and write the first request out. + template + ClientReader(Channel* channel, const RpcMethod& method, + ClientContext* context, const W& request) + : context_(context), call_(channel->CreateCall(method, context, &cq_)) { + CallOpSet ops; + ops.SendInitialMetadata(context->send_initial_metadata_); + // TODO(ctiller): don't assert + GPR_ASSERT(ops.SendMessage(request).ok()); + ops.ClientSendClose(); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } + + // Blocking wait for initial metadata from server. The received metadata + // can only be accessed after this call returns. Should only be called before + // the first read. Calling this method is optional, and if it is not called + // the metadata will be available in ClientContext after the first read. + void WaitForInitialMetadata() { + GPR_ASSERT(!context_->initial_metadata_received_); + + CallOpSet ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); // status ignored + } + + bool Read(R* msg) GRPC_OVERRIDE { + CallOpSet> ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ops.RecvMessage(msg); + call_.PerformOps(&ops); + return cq_.Pluck(&ops) && ops.got_message; + } + + Status Finish() GRPC_OVERRIDE { + CallOpSet ops; + Status status; + ops.ClientRecvStatus(context_, &status); + call_.PerformOps(&ops); + GPR_ASSERT(cq_.Pluck(&ops)); + return status; + } + + private: + ClientContext* context_; + CompletionQueue cq_; + Call call_; +}; + +template +class ClientWriterInterface : public ClientStreamingInterface, + public WriterInterface { + public: + virtual bool WritesDone() = 0; +}; + +template +class ClientWriter : public ClientWriterInterface { + public: + // Blocking create a stream. + template + ClientWriter(Channel* channel, const RpcMethod& method, + ClientContext* context, R* response) + : context_(context), call_(channel->CreateCall(method, context, &cq_)) { + finish_ops_.RecvMessage(response); + + CallOpSet ops; + ops.SendInitialMetadata(context->send_initial_metadata_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } + + using WriterInterface::Write; + bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { + CallOpSet ops; + if (!ops.SendMessage(msg, options).ok()) { + return false; + } + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + bool WritesDone() GRPC_OVERRIDE { + CallOpSet ops; + ops.ClientSendClose(); + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + // Read the final response and wait for the final status. + Status Finish() GRPC_OVERRIDE { + Status status; + finish_ops_.ClientRecvStatus(context_, &status); + call_.PerformOps(&finish_ops_); + GPR_ASSERT(cq_.Pluck(&finish_ops_)); + return status; + } + + private: + ClientContext* context_; + CallOpSet finish_ops_; + CompletionQueue cq_; + Call call_; +}; + +// Client-side interface for bi-directional streaming. +template +class ClientReaderWriterInterface : public ClientStreamingInterface, + public WriterInterface, + public ReaderInterface { + public: + virtual void WaitForInitialMetadata() = 0; + virtual bool WritesDone() = 0; +}; + +template +class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { + public: + // Blocking create a stream. + ClientReaderWriter(Channel* channel, const RpcMethod& method, + ClientContext* context) + : context_(context), call_(channel->CreateCall(method, context, &cq_)) { + CallOpSet ops; + ops.SendInitialMetadata(context->send_initial_metadata_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } + + // Blocking wait for initial metadata from server. The received metadata + // can only be accessed after this call returns. Should only be called before + // the first read. Calling this method is optional, and if it is not called + // the metadata will be available in ClientContext after the first read. + void WaitForInitialMetadata() { + GPR_ASSERT(!context_->initial_metadata_received_); + + CallOpSet ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); // status ignored + } + + bool Read(R* msg) GRPC_OVERRIDE { + CallOpSet> ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ops.RecvMessage(msg); + call_.PerformOps(&ops); + return cq_.Pluck(&ops) && ops.got_message; + } + + using WriterInterface::Write; + bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { + CallOpSet ops; + if (!ops.SendMessage(msg, options).ok()) return false; + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + bool WritesDone() GRPC_OVERRIDE { + CallOpSet ops; + ops.ClientSendClose(); + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + Status Finish() GRPC_OVERRIDE { + CallOpSet ops; + Status status; + ops.ClientRecvStatus(context_, &status); + call_.PerformOps(&ops); + GPR_ASSERT(cq_.Pluck(&ops)); + return status; + } + + private: + ClientContext* context_; + CompletionQueue cq_; + Call call_; +}; + +template +class ServerReader GRPC_FINAL : public ReaderInterface { + public: + ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + GPR_ASSERT(!ctx_->sent_initial_metadata_); + + CallOpSet ops; + ops.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + bool Read(R* msg) GRPC_OVERRIDE { + CallOpSet> ops; + ops.RecvMessage(msg); + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops) && ops.got_message; + } + + private: + Call* const call_; + ServerContext* const ctx_; +}; + +template +class ServerWriter GRPC_FINAL : public WriterInterface { + public: + ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + GPR_ASSERT(!ctx_->sent_initial_metadata_); + + CallOpSet ops; + ops.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + using WriterInterface::Write; + bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { + CallOpSet ops; + if (!ops.SendMessage(msg, options).ok()) { + return false; + } + if (!ctx_->sent_initial_metadata_) { + ops.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops); + } + + private: + Call* const call_; + ServerContext* const ctx_; +}; + +// Server-side interface for bi-directional streaming. +template +class ServerReaderWriter GRPC_FINAL : public WriterInterface, + public ReaderInterface { + public: + ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + GPR_ASSERT(!ctx_->sent_initial_metadata_); + + CallOpSet ops; + ops.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + bool Read(R* msg) GRPC_OVERRIDE { + CallOpSet> ops; + ops.RecvMessage(msg); + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops) && ops.got_message; + } + + using WriterInterface::Write; + bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { + CallOpSet ops; + if (!ops.SendMessage(msg, options).ok()) { + return false; + } + if (!ctx_->sent_initial_metadata_) { + ops.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops); + } + + private: + Call* const call_; + ServerContext* const ctx_; +}; + +// Async interfaces +// Common interface for all client side streaming. +class ClientAsyncStreamingInterface { + public: + virtual ~ClientAsyncStreamingInterface() {} + + virtual void ReadInitialMetadata(void* tag) = 0; + + virtual void Finish(Status* status, void* tag) = 0; +}; + +// An interface that yields a sequence of R messages. +template +class AsyncReaderInterface { + public: + virtual ~AsyncReaderInterface() {} + + virtual void Read(R* msg, void* tag) = 0; +}; + +// An interface that can be fed a sequence of W messages. +template +class AsyncWriterInterface { + public: + virtual ~AsyncWriterInterface() {} + + virtual void Write(const W& msg, void* tag) = 0; +}; + +template +class ClientAsyncReaderInterface : public ClientAsyncStreamingInterface, + public AsyncReaderInterface {}; + +template +class ClientAsyncReader GRPC_FINAL : public ClientAsyncReaderInterface { + public: + // Create a stream and write the first request out. + template + ClientAsyncReader(Channel* channel, CompletionQueue* cq, + const RpcMethod& method, ClientContext* context, + const W& request, void* tag) + : context_(context), call_(channel->CreateCall(method, context, cq)) { + init_ops_.set_output_tag(tag); + init_ops_.SendInitialMetadata(context->send_initial_metadata_); + // TODO(ctiller): don't assert + GPR_ASSERT(init_ops_.SendMessage(request).ok()); + init_ops_.ClientSendClose(); + call_.PerformOps(&init_ops_); + } + + void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) GRPC_OVERRIDE { + read_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + read_ops_.RecvInitialMetadata(context_); + } + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Finish(Status* status, void* tag) GRPC_OVERRIDE { + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + ClientContext* context_; + Call call_; + CallOpSet + init_ops_; + CallOpSet meta_ops_; + CallOpSet> read_ops_; + CallOpSet finish_ops_; +}; + +template +class ClientAsyncWriterInterface : public ClientAsyncStreamingInterface, + public AsyncWriterInterface { + public: + virtual void WritesDone(void* tag) = 0; +}; + +template +class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface { + public: + template + ClientAsyncWriter(Channel* channel, CompletionQueue* cq, + const RpcMethod& method, ClientContext* context, + R* response, void* tag) + : context_(context), call_(channel->CreateCall(method, context, cq)) { + finish_ops_.RecvMessage(response); + + init_ops_.set_output_tag(tag); + init_ops_.SendInitialMetadata(context->send_initial_metadata_); + call_.PerformOps(&init_ops_); + } + + void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Write(const W& msg, void* tag) GRPC_OVERRIDE { + write_ops_.set_output_tag(tag); + // TODO(ctiller): don't assert + GPR_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void WritesDone(void* tag) GRPC_OVERRIDE { + writes_done_ops_.set_output_tag(tag); + writes_done_ops_.ClientSendClose(); + call_.PerformOps(&writes_done_ops_); + } + + void Finish(Status* status, void* tag) GRPC_OVERRIDE { + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + ClientContext* context_; + Call call_; + CallOpSet init_ops_; + CallOpSet meta_ops_; + CallOpSet write_ops_; + CallOpSet writes_done_ops_; + CallOpSet finish_ops_; +}; + +// Client-side interface for bi-directional streaming. +template +class ClientAsyncReaderWriterInterface : public ClientAsyncStreamingInterface, + public AsyncWriterInterface, + public AsyncReaderInterface { + public: + virtual void WritesDone(void* tag) = 0; +}; + +template +class ClientAsyncReaderWriter GRPC_FINAL + : public ClientAsyncReaderWriterInterface { + public: + ClientAsyncReaderWriter(Channel* channel, CompletionQueue* cq, + const RpcMethod& method, ClientContext* context, + void* tag) + : context_(context), call_(channel->CreateCall(method, context, cq)) { + init_ops_.set_output_tag(tag); + init_ops_.SendInitialMetadata(context->send_initial_metadata_); + call_.PerformOps(&init_ops_); + } + + void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) GRPC_OVERRIDE { + read_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + read_ops_.RecvInitialMetadata(context_); + } + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Write(const W& msg, void* tag) GRPC_OVERRIDE { + write_ops_.set_output_tag(tag); + // TODO(ctiller): don't assert + GPR_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void WritesDone(void* tag) GRPC_OVERRIDE { + writes_done_ops_.set_output_tag(tag); + writes_done_ops_.ClientSendClose(); + call_.PerformOps(&writes_done_ops_); + } + + void Finish(Status* status, void* tag) GRPC_OVERRIDE { + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + ClientContext* context_; + Call call_; + CallOpSet init_ops_; + CallOpSet meta_ops_; + CallOpSet> read_ops_; + CallOpSet write_ops_; + CallOpSet writes_done_ops_; + CallOpSet finish_ops_; +}; + +template +class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, + public AsyncReaderInterface { + public: + explicit ServerAsyncReader(ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + void SendInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) GRPC_OVERRIDE { + read_ops_.set_output_tag(tag); + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Finish(const W& msg, const Status& status, void* tag) { + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (status.ok()) { + finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, + finish_ops_.SendMessage(msg)); + } else { + finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); + } + call_.PerformOps(&finish_ops_); + } + + void FinishWithError(const Status& status, void* tag) { + GPR_ASSERT(!status.ok()); + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } + + Call call_; + ServerContext* ctx_; + CallOpSet meta_ops_; + CallOpSet> read_ops_; + CallOpSet finish_ops_; +}; + +template +class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, + public AsyncWriterInterface { + public: + explicit ServerAsyncWriter(ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + void SendInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Write(const W& msg, void* tag) GRPC_OVERRIDE { + write_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + // TODO(ctiller): don't assert + GPR_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Finish(const Status& status, void* tag) { + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } + + Call call_; + ServerContext* ctx_; + CallOpSet meta_ops_; + CallOpSet write_ops_; + CallOpSet finish_ops_; +}; + +// Server-side interface for bi-directional streaming. +template +class ServerAsyncReaderWriter GRPC_FINAL : public ServerAsyncStreamingInterface, + public AsyncWriterInterface, + public AsyncReaderInterface { + public: + explicit ServerAsyncReaderWriter(ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + void SendInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) GRPC_OVERRIDE { + read_ops_.set_output_tag(tag); + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Write(const W& msg, void* tag) GRPC_OVERRIDE { + write_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + // TODO(ctiller): don't assert + GPR_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Finish(const Status& status, void* tag) { + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } + + Call call_; + ServerContext* ctx_; + CallOpSet meta_ops_; + CallOpSet> read_ops_; + CallOpSet write_ops_; + CallOpSet finish_ops_; +}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_STREAM_H diff --git a/include/grpc++/support/stub_options.h b/include/grpc++/support/stub_options.h new file mode 100644 index 0000000000..973aa9bc83 --- /dev/null +++ b/include/grpc++/support/stub_options.h @@ -0,0 +1,43 @@ +/* + * + * 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 GRPCXX_SUPPORT_STUB_OPTIONS_H +#define GRPCXX_SUPPORT_STUB_OPTIONS_H + +namespace grpc { + +class StubOptions {}; + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_STUB_OPTIONS_H diff --git a/include/grpc++/support/thread_pool_interface.h b/include/grpc++/support/thread_pool_interface.h new file mode 100644 index 0000000000..6528e7276f --- /dev/null +++ b/include/grpc++/support/thread_pool_interface.h @@ -0,0 +1,54 @@ +/* + * + * 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 GRPCXX_SUPPORT_THREAD_POOL_INTERFACE_H +#define GRPCXX_SUPPORT_THREAD_POOL_INTERFACE_H + +#include + +namespace grpc { + +// A thread pool interface for running callbacks. +class ThreadPoolInterface { + public: + virtual ~ThreadPoolInterface() {} + + // Schedule the given callback for execution. + virtual void Add(const std::function& callback) = 0; +}; + +ThreadPoolInterface* CreateDefaultThreadPool(); + +} // namespace grpc + +#endif // GRPCXX_SUPPORT_THREAD_POOL_INTERFACE_H diff --git a/include/grpc++/support/time.h b/include/grpc++/support/time.h new file mode 100644 index 0000000000..2d4196b93b --- /dev/null +++ b/include/grpc++/support/time.h @@ -0,0 +1,110 @@ +/* + * + * 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 GRPCXX_SUPPORT_TIME_H +#define GRPCXX_SUPPORT_TIME_H + +#include + +namespace grpc { + +/* If you are trying to use CompletionQueue::AsyncNext with a time class that + isn't either gpr_timespec or std::chrono::system_clock::time_point, you + will most likely be looking at this comment as your compiler will have + fired an error below. In order to fix this issue, you have two potential + solutions: + + 1. Use gpr_timespec or std::chrono::system_clock::time_point instead + 2. Specialize the TimePoint class with whichever time class that you + want to use here. See below for two examples of how to do this. + */ + +template +class TimePoint { + public: + TimePoint(const T& time) { you_need_a_specialization_of_TimePoint(); } + gpr_timespec raw_time() { + gpr_timespec t; + return t; + } + + private: + void you_need_a_specialization_of_TimePoint(); +}; + +template <> +class TimePoint { + public: + TimePoint(const gpr_timespec& time) : time_(time) {} + gpr_timespec raw_time() { return time_; } + + private: + gpr_timespec time_; +}; + +} // namespace grpc + +#ifndef GRPC_CXX0X_NO_CHRONO + +#include + +#include + +namespace grpc { + +// from and to should be absolute time. +void Timepoint2Timespec(const std::chrono::system_clock::time_point& from, + gpr_timespec* to); +void TimepointHR2Timespec( + const std::chrono::high_resolution_clock::time_point& from, + gpr_timespec* to); + +std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t); + +template <> +class TimePoint { + public: + TimePoint(const std::chrono::system_clock::time_point& time) { + Timepoint2Timespec(time, &time_); + } + gpr_timespec raw_time() const { return time_; } + + private: + gpr_timespec time_; +}; + +} // namespace grpc + +#endif // !GRPC_CXX0X_NO_CHRONO + +#endif // GRPCXX_SUPPORT_TIME_H diff --git a/include/grpc++/thread_pool_interface.h b/include/grpc++/thread_pool_interface.h deleted file mode 100644 index d080b31dcc..0000000000 --- a/include/grpc++/thread_pool_interface.h +++ /dev/null @@ -1,54 +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 GRPCXX_THREAD_POOL_INTERFACE_H -#define GRPCXX_THREAD_POOL_INTERFACE_H - -#include - -namespace grpc { - -// A thread pool interface for running callbacks. -class ThreadPoolInterface { - public: - virtual ~ThreadPoolInterface() {} - - // Schedule the given callback for execution. - virtual void Add(const std::function& callback) = 0; -}; - -ThreadPoolInterface* CreateDefaultThreadPool(); - -} // namespace grpc - -#endif // GRPCXX_THREAD_POOL_INTERFACE_H diff --git a/include/grpc++/time.h b/include/grpc++/time.h deleted file mode 100644 index 8fb2f8505c..0000000000 --- a/include/grpc++/time.h +++ /dev/null @@ -1,110 +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 GRPCXX_TIME_H -#define GRPCXX_TIME_H - -#include - -namespace grpc { - -/* If you are trying to use CompletionQueue::AsyncNext with a time class that - isn't either gpr_timespec or std::chrono::system_clock::time_point, you - will most likely be looking at this comment as your compiler will have - fired an error below. In order to fix this issue, you have two potential - solutions: - - 1. Use gpr_timespec or std::chrono::system_clock::time_point instead - 2. Specialize the TimePoint class with whichever time class that you - want to use here. See below for two examples of how to do this. - */ - -template -class TimePoint { - public: - TimePoint(const T& time) { you_need_a_specialization_of_TimePoint(); } - gpr_timespec raw_time() { - gpr_timespec t; - return t; - } - - private: - void you_need_a_specialization_of_TimePoint(); -}; - -template <> -class TimePoint { - public: - TimePoint(const gpr_timespec& time) : time_(time) {} - gpr_timespec raw_time() { return time_; } - - private: - gpr_timespec time_; -}; - -} // namespace grpc - -#ifndef GRPC_CXX0X_NO_CHRONO - -#include - -#include - -namespace grpc { - -// from and to should be absolute time. -void Timepoint2Timespec(const std::chrono::system_clock::time_point& from, - gpr_timespec* to); -void TimepointHR2Timespec( - const std::chrono::high_resolution_clock::time_point& from, - gpr_timespec* to); - -std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t); - -template <> -class TimePoint { - public: - TimePoint(const std::chrono::system_clock::time_point& time) { - Timepoint2Timespec(time, &time_); - } - gpr_timespec raw_time() const { return time_; } - - private: - gpr_timespec time_; -}; - -} // namespace grpc - -#endif // !GRPC_CXX0X_NO_CHRONO - -#endif // GRPCXX_TIME_H diff --git a/src/compiler/config.h b/src/compiler/config.h index cd52aca57d..fea976c318 100644 --- a/src/compiler/config.h +++ b/src/compiler/config.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPILER_CONFIG_H #define SRC_COMPILER_CONFIG_H -#include -#include +#include +#include #ifndef GRPC_CUSTOM_DESCRIPTOR #include diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index b04ac038ad..5d82b605fb 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -115,10 +115,10 @@ grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file, "#include \n" "#include \n" "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" "\n" "namespace grpc {\n" "class CompletionQueue;\n" @@ -701,12 +701,12 @@ grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file, grpc::protobuf::io::Printer printer(&output_stream, '$'); std::map vars; - printer.Print(vars, "#include \n"); printer.Print(vars, "#include \n"); printer.Print(vars, "#include \n"); printer.Print(vars, "#include \n"); printer.Print(vars, "#include \n"); - printer.Print(vars, "#include \n"); + printer.Print(vars, "#include \n"); + printer.Print(vars, "#include \n"); if (!file->package().empty()) { std::vector parts = diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index 2982a89fad..72c457ac6b 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -42,7 +42,7 @@ #include #include -#include +#include #include "src/compiler/config.h" #include "src/compiler/generator_helpers.h" #include "src/compiler/python_generator.h" diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc index bb4be07beb..8bf2e4687e 100644 --- a/src/cpp/client/channel.cc +++ b/src/cpp/client/channel.cc @@ -38,17 +38,16 @@ #include #include #include - -#include "src/core/profiling/timers.h" -#include #include #include -#include #include #include #include -#include -#include +#include +#include +#include +#include +#include "src/core/profiling/timers.h" namespace grpc { diff --git a/src/cpp/client/channel_arguments.cc b/src/cpp/client/channel_arguments.cc index da6602e7af..50422d06c9 100644 --- a/src/cpp/client/channel_arguments.cc +++ b/src/cpp/client/channel_arguments.cc @@ -31,10 +31,9 @@ * */ -#include +#include #include - #include "src/core/channel/channel_args.h" namespace grpc { diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index a3906fc781..c4d7cf2e51 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include "src/core/channel/compress_filter.h" #include "src/cpp/common/create_auth_context.h" diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc index 70ea7e0e27..8c571cbbaa 100644 --- a/src/cpp/client/create_channel.cc +++ b/src/cpp/client/create_channel.cc @@ -35,8 +35,8 @@ #include #include -#include #include +#include #include "src/cpp/client/create_channel_internal.h" diff --git a/src/cpp/client/create_channel_internal.h b/src/cpp/client/create_channel_internal.h index 1692471990..4385ec701e 100644 --- a/src/cpp/client/create_channel_internal.h +++ b/src/cpp/client/create_channel_internal.h @@ -36,7 +36,7 @@ #include -#include +#include struct grpc_channel; diff --git a/src/cpp/client/generic_stub.cc b/src/cpp/client/generic_stub.cc index ee89c02965..7a2fdf941c 100644 --- a/src/cpp/client/generic_stub.cc +++ b/src/cpp/client/generic_stub.cc @@ -31,7 +31,7 @@ * */ -#include +#include #include diff --git a/src/cpp/client/insecure_credentials.cc b/src/cpp/client/insecure_credentials.cc index 97931406af..4a4d2cb97d 100644 --- a/src/cpp/client/insecure_credentials.cc +++ b/src/cpp/client/insecure_credentials.cc @@ -31,13 +31,13 @@ * */ +#include + #include #include - #include -#include -#include -#include +#include +#include #include "src/cpp/client/create_channel_internal.h" namespace grpc { diff --git a/src/cpp/client/secure_channel_arguments.cc b/src/cpp/client/secure_channel_arguments.cc index d89df999ad..e17d3b58b0 100644 --- a/src/cpp/client/secure_channel_arguments.cc +++ b/src/cpp/client/secure_channel_arguments.cc @@ -31,9 +31,9 @@ * */ -#include -#include +#include +#include #include "src/core/channel/channel_args.h" namespace grpc { diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 1e912c6beb..f368f2590a 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -33,8 +33,8 @@ #include #include -#include #include +#include #include "src/cpp/client/create_channel_internal.h" #include "src/cpp/client/secure_credentials.h" diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h index 974d83514d..62d3185477 100644 --- a/src/cpp/client/secure_credentials.h +++ b/src/cpp/client/secure_credentials.h @@ -36,7 +36,7 @@ #include -#include +#include #include namespace grpc { diff --git a/src/cpp/common/auth_property_iterator.cc b/src/cpp/common/auth_property_iterator.cc index d3bfd5cb6b..5ccf8cf72c 100644 --- a/src/cpp/common/auth_property_iterator.cc +++ b/src/cpp/common/auth_property_iterator.cc @@ -31,7 +31,7 @@ * */ -#include +#include #include diff --git a/src/cpp/common/call.cc b/src/cpp/common/call.cc index 479f14d42b..16aa2c9fb9 100644 --- a/src/cpp/common/call.cc +++ b/src/cpp/common/call.cc @@ -34,10 +34,9 @@ #include #include -#include -#include #include - +#include +#include #include "src/core/profiling/timers.h" namespace grpc { diff --git a/src/cpp/common/completion_queue.cc b/src/cpp/common/completion_queue.cc index fca33f8f54..a175beb452 100644 --- a/src/cpp/common/completion_queue.cc +++ b/src/cpp/common/completion_queue.cc @@ -36,7 +36,7 @@ #include #include -#include +#include namespace grpc { diff --git a/src/cpp/common/create_auth_context.h b/src/cpp/common/create_auth_context.h index 9082a90c6d..b4962bae4e 100644 --- a/src/cpp/common/create_auth_context.h +++ b/src/cpp/common/create_auth_context.h @@ -33,7 +33,7 @@ #include #include -#include +#include namespace grpc { diff --git a/src/cpp/common/insecure_create_auth_context.cc b/src/cpp/common/insecure_create_auth_context.cc index 07fc0bd549..fe80c1a80c 100644 --- a/src/cpp/common/insecure_create_auth_context.cc +++ b/src/cpp/common/insecure_create_auth_context.cc @@ -33,7 +33,7 @@ #include #include -#include +#include namespace grpc { diff --git a/src/cpp/common/secure_auth_context.h b/src/cpp/common/secure_auth_context.h index 264ed620a3..01b7126189 100644 --- a/src/cpp/common/secure_auth_context.h +++ b/src/cpp/common/secure_auth_context.h @@ -34,7 +34,7 @@ #ifndef GRPC_INTERNAL_CPP_COMMON_SECURE_AUTH_CONTEXT_H #define GRPC_INTERNAL_CPP_COMMON_SECURE_AUTH_CONTEXT_H -#include +#include struct grpc_auth_context; diff --git a/src/cpp/common/secure_create_auth_context.cc b/src/cpp/common/secure_create_auth_context.cc index d81f4bbc4a..f13d25a1dd 100644 --- a/src/cpp/common/secure_create_auth_context.cc +++ b/src/cpp/common/secure_create_auth_context.cc @@ -34,7 +34,7 @@ #include #include -#include +#include #include "src/cpp/common/secure_auth_context.h" namespace grpc { diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc index 05470ec627..be84c222a0 100644 --- a/src/cpp/proto/proto_utils.cc +++ b/src/cpp/proto/proto_utils.cc @@ -32,7 +32,6 @@ */ #include -#include #include #include @@ -40,6 +39,7 @@ #include #include #include +#include const int kMaxBufferLength = 8192; diff --git a/src/cpp/server/async_generic_service.cc b/src/cpp/server/async_generic_service.cc index 2e99afcb5f..6b9ea532b6 100644 --- a/src/cpp/server/async_generic_service.cc +++ b/src/cpp/server/async_generic_service.cc @@ -31,7 +31,7 @@ * */ -#include +#include #include diff --git a/src/cpp/server/create_default_thread_pool.cc b/src/cpp/server/create_default_thread_pool.cc index 9f59d254f1..0eef7dfffe 100644 --- a/src/cpp/server/create_default_thread_pool.cc +++ b/src/cpp/server/create_default_thread_pool.cc @@ -32,7 +32,7 @@ */ #include -#include +#include #ifndef GRPC_CUSTOM_DEFAULT_THREAD_POOL diff --git a/src/cpp/server/dynamic_thread_pool.cc b/src/cpp/server/dynamic_thread_pool.cc index b475f43b1d..d33852364d 100644 --- a/src/cpp/server/dynamic_thread_pool.cc +++ b/src/cpp/server/dynamic_thread_pool.cc @@ -33,7 +33,7 @@ #include #include -#include +#include namespace grpc { DynamicThreadPool::DynamicThread::DynamicThread(DynamicThreadPool* pool) diff --git a/src/cpp/server/fixed_size_thread_pool.cc b/src/cpp/server/fixed_size_thread_pool.cc index bafbc5802a..427e904449 100644 --- a/src/cpp/server/fixed_size_thread_pool.cc +++ b/src/cpp/server/fixed_size_thread_pool.cc @@ -33,7 +33,7 @@ #include #include -#include +#include namespace grpc { diff --git a/src/cpp/server/secure_server_credentials.h b/src/cpp/server/secure_server_credentials.h index b9803f107e..d3d37b188d 100644 --- a/src/cpp/server/secure_server_credentials.h +++ b/src/cpp/server/secure_server_credentials.h @@ -34,10 +34,10 @@ #ifndef GRPC_INTERNAL_CPP_SERVER_SECURE_SERVER_CREDENTIALS_H #define GRPC_INTERNAL_CPP_SERVER_SECURE_SERVER_CREDENTIALS_H -#include - #include +#include + namespace grpc { class SecureServerCredentials GRPC_FINAL : public ServerCredentials { diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index e039c07374..568bb8ad5e 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -32,19 +32,20 @@ */ #include + #include #include #include #include #include -#include +#include #include #include #include #include -#include -#include +#include +#include #include "src/core/profiling/timers.h" diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 0b11d86173..4e8399405e 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -37,8 +37,8 @@ #include #include #include -#include -#include +#include +#include namespace grpc { diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index 03461ddda5..acc163d6b5 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include "src/core/channel/compress_filter.h" #include "src/cpp/common/create_auth_context.h" diff --git a/src/cpp/util/byte_buffer.cc b/src/cpp/util/byte_buffer.cc index a66c92c3e1..e46e656beb 100644 --- a/src/cpp/util/byte_buffer.cc +++ b/src/cpp/util/byte_buffer.cc @@ -32,7 +32,7 @@ */ #include -#include +#include namespace grpc { diff --git a/src/cpp/util/slice.cc b/src/cpp/util/slice.cc index 57370dabc6..7e88423b6c 100644 --- a/src/cpp/util/slice.cc +++ b/src/cpp/util/slice.cc @@ -31,7 +31,7 @@ * */ -#include +#include namespace grpc { diff --git a/src/cpp/util/status.cc b/src/cpp/util/status.cc index 5bb9eda3d9..ad9850cf07 100644 --- a/src/cpp/util/status.cc +++ b/src/cpp/util/status.cc @@ -31,7 +31,7 @@ * */ -#include +#include namespace grpc { diff --git a/src/cpp/util/time.cc b/src/cpp/util/time.cc index 799c597e0b..b3401eb26b 100644 --- a/src/cpp/util/time.cc +++ b/src/cpp/util/time.cc @@ -31,12 +31,12 @@ * */ -#include +#include #ifndef GRPC_CXX0X_NO_CHRONO #include -#include +#include using std::chrono::duration_cast; using std::chrono::nanoseconds; diff --git a/test/cpp/client/channel_arguments_test.cc b/test/cpp/client/channel_arguments_test.cc index 01c56cb795..3d75e7b0e6 100644 --- a/test/cpp/client/channel_arguments_test.cc +++ b/test/cpp/client/channel_arguments_test.cc @@ -31,7 +31,7 @@ * */ -#include +#include #include #include diff --git a/test/cpp/common/auth_property_iterator_test.cc b/test/cpp/common/auth_property_iterator_test.cc index bf17842a84..630c38c7f6 100644 --- a/test/cpp/common/auth_property_iterator_test.cc +++ b/test/cpp/common/auth_property_iterator_test.cc @@ -32,7 +32,7 @@ */ #include -#include +#include #include #include "src/cpp/common/secure_auth_context.h" diff --git a/test/cpp/common/secure_auth_context_test.cc b/test/cpp/common/secure_auth_context_test.cc index e0376c9cc7..c71ef58023 100644 --- a/test/cpp/common/secure_auth_context_test.cc +++ b/test/cpp/common/secure_auth_context_test.cc @@ -32,7 +32,7 @@ */ #include -#include +#include #include #include "src/cpp/common/secure_auth_context.h" diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 7006ebb83a..f81043d610 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -33,12 +33,9 @@ #include -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/echo_duplicate.grpc.pb.h" -#include "test/cpp/util/echo.grpc.pb.h" -#include -#include +#include +#include +#include #include #include #include @@ -47,14 +44,12 @@ #include #include #include -#include -#include -#include #include -#include -#include -#include +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo_duplicate.grpc.pb.h" +#include "test/cpp/util/echo.grpc.pb.h" using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoResponse; diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc index 89708a2ef6..3359080cec 100644 --- a/test/cpp/end2end/client_crash_test.cc +++ b/test/cpp/end2end/client_crash_test.cc @@ -31,11 +31,9 @@ * */ -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/echo_duplicate.grpc.pb.h" -#include "test/cpp/util/echo.grpc.pb.h" -#include +#include +#include +#include #include #include #include @@ -44,15 +42,12 @@ #include #include #include -#include -#include -#include #include -#include -#include -#include - +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo_duplicate.grpc.pb.h" +#include "test/cpp/util/echo.grpc.pb.h" #include "test/cpp/util/subprocess.h" using grpc::cpp::test::util::EchoRequest; diff --git a/test/cpp/end2end/client_crash_test_server.cc b/test/cpp/end2end/client_crash_test_server.cc index 3fd8c2c2f9..79a7832874 100644 --- a/test/cpp/end2end/client_crash_test_server.cc +++ b/test/cpp/end2end/client_crash_test_server.cc @@ -40,7 +40,6 @@ #include #include #include -#include #include "test/cpp/util/echo.grpc.pb.h" DEFINE_string(address, "", "Address to bind to"); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index fc4e88c2a7..1b83eb4b3c 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -34,30 +34,26 @@ #include #include -#include "src/core/security/credentials.h" -#include "test/core/end2end/data/ssl_test_data.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/echo_duplicate.grpc.pb.h" -#include "test/cpp/util/echo.grpc.pb.h" -#include +#include +#include +#include #include #include #include #include -#include #include #include #include #include -#include -#include -#include +#include #include -#include -#include -#include +#include "src/core/security/credentials.h" +#include "test/core/end2end/data/ssl_test_data.h" +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo_duplicate.grpc.pb.h" +#include "test/cpp/util/echo.grpc.pb.h" using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoResponse; diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index b817198fa7..de7eab8dc2 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -33,32 +33,26 @@ #include -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/echo.grpc.pb.h" +#include +#include +#include #include -#include -#include -#include -#include #include #include #include #include -#include +#include +#include #include #include #include #include -#include -#include -#include -#include +#include #include -#include -#include -#include +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo.grpc.pb.h" using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoResponse; diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 96b6ecbd6e..a547cfc67e 100644 --- a/test/cpp/end2end/mock_test.cc +++ b/test/cpp/end2end/mock_test.cc @@ -33,28 +33,24 @@ #include -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/echo_duplicate.grpc.pb.h" -#include "test/cpp/util/echo.grpc.pb.h" -#include +#include +#include +#include #include #include #include #include -#include #include #include #include #include -#include -#include -#include +#include #include -#include -#include -#include +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo_duplicate.grpc.pb.h" +#include "test/cpp/util/echo.grpc.pb.h" using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoResponse; diff --git a/test/cpp/end2end/server_crash_test.cc b/test/cpp/end2end/server_crash_test.cc index 2688f2c4ea..1a0f04e22b 100644 --- a/test/cpp/end2end/server_crash_test.cc +++ b/test/cpp/end2end/server_crash_test.cc @@ -31,11 +31,9 @@ * */ -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/echo_duplicate.grpc.pb.h" -#include "test/cpp/util/echo.grpc.pb.h" -#include +#include +#include +#include #include #include #include @@ -44,15 +42,12 @@ #include #include #include -#include -#include -#include #include -#include -#include -#include - +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo.grpc.pb.h" +#include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/subprocess.h" using grpc::cpp::test::util::EchoRequest; diff --git a/test/cpp/end2end/server_crash_test_client.cc b/test/cpp/end2end/server_crash_test_client.cc index 52dce8f28e..7ca43a0c5b 100644 --- a/test/cpp/end2end/server_crash_test_client.cc +++ b/test/cpp/end2end/server_crash_test_client.cc @@ -37,12 +37,10 @@ #include #include -#include #include #include #include #include -#include #include "test/cpp/util/echo.grpc.pb.h" DEFINE_string(address, "", "Address to connect to"); diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc index dc5fb5af9b..e83f86f7ec 100644 --- a/test/cpp/end2end/shutdown_test.cc +++ b/test/cpp/end2end/shutdown_test.cc @@ -31,14 +31,10 @@ * */ -#include "test/core/util/test_config.h" - #include -#include "test/core/util/port.h" -#include "test/cpp/util/echo.grpc.pb.h" -#include "src/core/support/env.h" -#include +#include +#include #include #include #include @@ -47,10 +43,12 @@ #include #include #include -#include #include -#include -#include + +#include "src/core/support/env.h" +#include "test/core/util/test_config.h" +#include "test/core/util/port.h" +#include "test/cpp/util/echo.grpc.pb.h" using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoResponse; diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index e59a77dc9e..be436a2f6c 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -34,28 +34,24 @@ #include #include -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/echo_duplicate.grpc.pb.h" -#include "test/cpp/util/echo.grpc.pb.h" -#include +#include +#include +#include #include #include #include #include -#include +#include #include #include #include #include -#include -#include -#include #include -#include -#include -#include +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo_duplicate.grpc.pb.h" +#include "test/cpp/util/echo.grpc.pb.h" using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoResponse; diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc index d7fac3d07e..e7d95b1c46 100644 --- a/test/cpp/end2end/zookeeper_test.cc +++ b/test/cpp/end2end/zookeeper_test.cc @@ -31,11 +31,6 @@ * */ -#include "test/core/util/test_config.h" -#include "test/core/util/port.h" -#include "test/cpp/util/echo.grpc.pb.h" -#include "src/core/support/env.h" -#include #include #include #include @@ -44,12 +39,16 @@ #include #include #include -#include #include #include #include #include +#include "test/core/util/test_config.h" +#include "test/core/util/port.h" +#include "test/cpp/util/echo.grpc.pb.h" +#include "src/core/support/env.h" + using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoResponse; diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index d9e4f1ba6a..cb5232153b 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -40,8 +40,7 @@ #include #include #include -#include -#include + #include "test/cpp/interop/client_helper.h" #include "test/cpp/interop/interop_client.h" #include "test/cpp/util/test_config.h" diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index be652a4add..abc14aeb98 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -33,27 +33,24 @@ #include "test/cpp/interop/client_helper.h" +#include + #include #include #include -#include - #include #include #include #include -#include #include #include #include -#include +#include "src/cpp/client/secure_credentials.h" #include "test/core/security/oauth2_utils.h" #include "test/cpp/util/create_test_channel.h" -#include "src/cpp/client/secure_credentials.h" - DECLARE_bool(enable_ssl); DECLARE_bool(use_prod_roots); DECLARE_int32(server_port); diff --git a/test/cpp/interop/client_helper.h b/test/cpp/interop/client_helper.h index d4c14433a9..92d5078f48 100644 --- a/test/cpp/interop/client_helper.h +++ b/test/cpp/interop/client_helper.h @@ -36,7 +36,6 @@ #include -#include #include #include "src/core/surface/call.h" diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index c73505c670..fa358585d4 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -33,11 +33,11 @@ #include "test/cpp/interop/interop_client.h" +#include + #include #include -#include - #include #include #include @@ -45,14 +45,12 @@ #include #include #include -#include -#include +#include "src/core/transport/stream_op.h" #include "test/cpp/interop/client_helper.h" #include "test/proto/test.grpc.pb.h" #include "test/proto/empty.grpc.pb.h" #include "test/proto/messages.grpc.pb.h" -#include "src/core/transport/stream_op.h" namespace grpc { namespace testing { diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 354c2c6195..5e26cc82e6 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -33,11 +33,11 @@ #ifndef GRPC_TEST_CPP_INTEROP_INTEROP_CLIENT_H #define GRPC_TEST_CPP_INTEROP_INTEROP_CLIENT_H + #include #include #include -#include #include "test/proto/messages.grpc.pb.h" namespace grpc { diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc index aac6e56b89..f01b032e95 100644 --- a/test/cpp/interop/interop_test.cc +++ b/test/cpp/interop/interop_test.cc @@ -44,17 +44,18 @@ #include #include -extern "C" { -#include "src/core/iomgr/socket_utils_posix.h" -#include "src/core/support/string.h" -} - #include #include #include #include #include "test/core/util/port.h" +extern "C" { +#include "src/core/iomgr/socket_utils_posix.h" +#include "src/core/support/string.h" +} + + int test_client(const char* root, const char* host, int port) { int status; pid_t cli; diff --git a/test/cpp/interop/reconnect_interop_client.cc b/test/cpp/interop/reconnect_interop_client.cc index 675c6ff073..d332dcad84 100644 --- a/test/cpp/interop/reconnect_interop_client.cc +++ b/test/cpp/interop/reconnect_interop_client.cc @@ -39,7 +39,6 @@ #include #include #include -#include #include "test/cpp/util/create_test_channel.h" #include "test/cpp/util/test_config.h" #include "test/proto/test.grpc.pb.h" diff --git a/test/cpp/interop/reconnect_interop_server.cc b/test/cpp/interop/reconnect_interop_server.cc index 8bc51aa52e..d4f171b1d0 100644 --- a/test/cpp/interop/reconnect_interop_server.cc +++ b/test/cpp/interop/reconnect_interop_server.cc @@ -31,23 +31,22 @@ * */ +#include +#include + #include #include #include #include -#include -#include - #include #include #include -#include #include #include #include #include -#include + #include "test/core/util/reconnect_server.h" #include "test/cpp/util/test_config.h" #include "test/proto/test.grpc.pb.h" diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc index 760bb18f73..35ec890aa0 100644 --- a/test/cpp/interop/server.cc +++ b/test/cpp/interop/server.cc @@ -31,32 +31,28 @@ * */ +#include +#include + #include #include #include #include -#include -#include - #include #include #include #include - -#include #include #include #include #include -#include -#include +#include "test/cpp/interop/server_helper.h" +#include "test/cpp/util/test_config.h" #include "test/proto/test.grpc.pb.h" #include "test/proto/empty.grpc.pb.h" #include "test/proto/messages.grpc.pb.h" -#include "test/cpp/interop/server_helper.h" -#include "test/cpp/util/test_config.h" DEFINE_bool(enable_ssl, false, "Whether to use ssl/tls."); DEFINE_int32(port, 0, "Server port."); diff --git a/test/cpp/interop/server_helper.cc b/test/cpp/interop/server_helper.cc index 3721d79635..e897f4ebf0 100644 --- a/test/cpp/interop/server_helper.cc +++ b/test/cpp/interop/server_helper.cc @@ -36,7 +36,6 @@ #include #include -#include #include #include "src/core/surface/call.h" diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 5395d02e32..0f95cfea38 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -34,14 +34,14 @@ #ifndef TEST_QPS_CLIENT_H #define TEST_QPS_CLIENT_H +#include +#include + #include "test/cpp/qps/histogram.h" #include "test/cpp/qps/interarrival.h" #include "test/cpp/qps/timer.h" #include "test/cpp/qps/qpstest.grpc.pb.h" - -#include -#include -#include +#include "test/cpp/util/create_test_channel.h" namespace grpc { diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index a337610cbf..f779e4a577 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -46,14 +46,12 @@ #include #include #include -#include #include -#include -#include -#include "test/cpp/util/create_test_channel.h" + #include "test/cpp/qps/qpstest.grpc.pb.h" #include "test/cpp/qps/timer.h" #include "test/cpp/qps/client.h" +#include "test/cpp/util/create_test_channel.h" namespace grpc { namespace testing { diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index db5416a707..123dca6600 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -31,6 +31,8 @@ * */ +#include + #include #include #include @@ -40,21 +42,18 @@ #include #include -#include - +#include #include #include #include #include #include #include -#include #include #include #include -#include -#include #include + #include "test/cpp/util/create_test_channel.h" #include "test/cpp/qps/client.h" #include "test/cpp/qps/qpstest.grpc.pb.h" diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 78e3720938..3bd61ea4e8 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -31,24 +31,24 @@ * */ -#include "test/cpp/qps/driver.h" -#include "src/core/support/env.h" +#include +#include +#include +#include +#include + #include #include #include -#include #include #include -#include -#include -#include -#include -#include -#include -#include "test/cpp/qps/histogram.h" -#include "test/cpp/qps/qps_worker.h" + +#include "src/core/support/env.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" +#include "test/cpp/qps/driver.h" +#include "test/cpp/qps/histogram.h" +#include "test/cpp/qps/qps_worker.h" using std::list; using std::thread; diff --git a/test/cpp/qps/interarrival.h b/test/cpp/qps/interarrival.h index 04d14f689f..841619e3ff 100644 --- a/test/cpp/qps/interarrival.h +++ b/test/cpp/qps/interarrival.h @@ -39,7 +39,7 @@ #include #include -#include +#include namespace grpc { namespace testing { diff --git a/test/cpp/qps/perf_db_client.h b/test/cpp/qps/perf_db_client.h index 3433cd88d1..ae5d17074b 100644 --- a/test/cpp/qps/perf_db_client.h +++ b/test/cpp/qps/perf_db_client.h @@ -37,12 +37,11 @@ #include #include -#include +#include #include #include #include #include -#include #include "test/cpp/qps/perf_db.grpc.pb.h" namespace grpc { diff --git a/test/cpp/qps/qps_interarrival_test.cc b/test/cpp/qps/qps_interarrival_test.cc index 1eed956a1c..a7979e6187 100644 --- a/test/cpp/qps/qps_interarrival_test.cc +++ b/test/cpp/qps/qps_interarrival_test.cc @@ -31,13 +31,13 @@ * */ -#include "test/cpp/qps/interarrival.h" #include #include // Use the C histogram rather than C++ to avoid depending on proto #include -#include + +#include "test/cpp/qps/interarrival.h" using grpc::testing::RandomDist; using grpc::testing::InterarrivalTimer; diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc index 9a7313f6e8..5a6a9249a9 100644 --- a/test/cpp/qps/qps_openloop_test.cc +++ b/test/cpp/qps/qps_openloop_test.cc @@ -31,12 +31,12 @@ * */ +#include + #include #include -#include - #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" #include "test/cpp/util/benchmark_config.h" diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc index ba980a6664..d0c4a79cd9 100644 --- a/test/cpp/qps/qps_test.cc +++ b/test/cpp/qps/qps_test.cc @@ -31,12 +31,12 @@ * */ +#include + #include #include -#include - #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" #include "test/cpp/util/benchmark_config.h" diff --git a/test/cpp/qps/qps_test_with_poll.cc b/test/cpp/qps/qps_test_with_poll.cc index 90a8da8d11..31d2c1bf7b 100644 --- a/test/cpp/qps/qps_test_with_poll.cc +++ b/test/cpp/qps/qps_test_with_poll.cc @@ -31,12 +31,12 @@ * */ +#include + #include #include -#include - #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" #include "test/cpp/util/benchmark_config.h" diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index f1cea5ee66..51e955a80a 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -47,16 +47,15 @@ #include #include #include -#include #include #include #include -#include + #include "test/core/util/grpc_profiler.h" -#include "test/cpp/util/create_test_channel.h" #include "test/cpp/qps/qpstest.pb.h" #include "test/cpp/qps/client.h" #include "test/cpp/qps/server.h" +#include "test/cpp/util/create_test_channel.h" namespace grpc { namespace testing { diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index aec3cbe80a..620abade39 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -37,7 +37,8 @@ #include #include #include -#include + +#include #include "test/cpp/qps/driver.h" #include "test/cpp/qps/qpstest.grpc.pb.h" diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index b4fc49c31c..77415f42ce 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -41,22 +41,20 @@ #include #include +#include #include #include -#include -#include +#include +#include #include #include #include #include -#include -#include #include + #include "test/cpp/qps/qpstest.grpc.pb.h" #include "test/cpp/qps/server.h" -#include -#include namespace grpc { namespace testing { diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index 4c3c9cb497..c149fbc738 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -32,28 +32,25 @@ */ #include -#include - #include +#include #include +#include #include #include -#include -#include -#include +#include +#include +#include #include #include #include #include -#include -#include + #include "test/cpp/qps/qpstest.grpc.pb.h" #include "test/cpp/qps/server.h" #include "test/cpp/qps/timer.h" -#include -#include namespace grpc { namespace testing { diff --git a/test/cpp/qps/stats.h b/test/cpp/qps/stats.h index 82dc03e3da..93875017ca 100644 --- a/test/cpp/qps/stats.h +++ b/test/cpp/qps/stats.h @@ -34,9 +34,10 @@ #ifndef TEST_QPS_STATS_UTILS_H #define TEST_QPS_STATS_UTILS_H -#include "test/cpp/qps/histogram.h" #include +#include "test/cpp/qps/histogram.h" + namespace grpc { namespace testing { diff --git a/test/cpp/qps/sync_streaming_ping_pong_test.cc b/test/cpp/qps/sync_streaming_ping_pong_test.cc index d53905a779..52e43939a8 100644 --- a/test/cpp/qps/sync_streaming_ping_pong_test.cc +++ b/test/cpp/qps/sync_streaming_ping_pong_test.cc @@ -31,12 +31,12 @@ * */ +#include + #include #include -#include - #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" #include "test/cpp/util/benchmark_config.h" diff --git a/test/cpp/qps/sync_unary_ping_pong_test.cc b/test/cpp/qps/sync_unary_ping_pong_test.cc index d276d13a43..fbd21357aa 100644 --- a/test/cpp/qps/sync_unary_ping_pong_test.cc +++ b/test/cpp/qps/sync_unary_ping_pong_test.cc @@ -31,12 +31,12 @@ * */ +#include + #include #include -#include - #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" #include "test/cpp/util/benchmark_config.h" diff --git a/test/cpp/qps/timer.cc b/test/cpp/qps/timer.cc index c1ba23decd..8edb838da3 100644 --- a/test/cpp/qps/timer.cc +++ b/test/cpp/qps/timer.cc @@ -36,7 +36,6 @@ #include #include #include -#include Timer::Timer() : start_(Sample()) {} diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc index 7cf4903148..935e4853a6 100644 --- a/test/cpp/qps/worker.cc +++ b/test/cpp/qps/worker.cc @@ -36,9 +36,9 @@ #include #include +#include #include #include -#include #include "test/cpp/qps/qps_worker.h" #include "test/cpp/util/test_config.h" diff --git a/test/cpp/server/dynamic_thread_pool_test.cc b/test/cpp/server/dynamic_thread_pool_test.cc index 63b603b8f7..e978fd03f3 100644 --- a/test/cpp/server/dynamic_thread_pool_test.cc +++ b/test/cpp/server/dynamic_thread_pool_test.cc @@ -31,11 +31,12 @@ * */ +#include + #include #include #include -#include #include namespace grpc { diff --git a/test/cpp/server/fixed_size_thread_pool_test.cc b/test/cpp/server/fixed_size_thread_pool_test.cc index 442e974fc1..97953af224 100644 --- a/test/cpp/server/fixed_size_thread_pool_test.cc +++ b/test/cpp/server/fixed_size_thread_pool_test.cc @@ -31,11 +31,12 @@ * */ +#include + #include #include #include -#include #include namespace grpc { diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc index 5195575f99..f36c32cac5 100644 --- a/test/cpp/util/byte_buffer_test.cc +++ b/test/cpp/util/byte_buffer_test.cc @@ -31,13 +31,13 @@ * */ -#include +#include #include #include #include -#include +#include #include namespace grpc { diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index d0a300f511..d60cee9c02 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -35,16 +35,13 @@ #include -#include -#include -#include -#include -#include -#include - #include #include #include +#include +#include +#include +#include namespace grpc { namespace testing { diff --git a/test/cpp/util/cli_call.h b/test/cpp/util/cli_call.h index 46b5dd3e4f..7a3dcf2e9f 100644 --- a/test/cpp/util/cli_call.h +++ b/test/cpp/util/cli_call.h @@ -37,8 +37,7 @@ #include #include -#include -#include +#include namespace grpc { namespace testing { diff --git a/test/cpp/util/cli_call_test.cc b/test/cpp/util/cli_call_test.cc index 146e96720f..0d34009bd5 100644 --- a/test/cpp/util/cli_call_test.cc +++ b/test/cpp/util/cli_call_test.cc @@ -31,24 +31,23 @@ * */ -#include "test/core/util/test_config.h" #include "test/cpp/util/cli_call.h" -#include "test/cpp/util/echo.grpc.pb.h" -#include + +#include #include #include #include #include -#include +#include #include #include #include #include -#include -#include "test/core/util/port.h" #include -#include +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo.grpc.pb.h" using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoResponse; diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index 43e719ef6b..161b4bdc1d 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -33,11 +33,11 @@ #include "test/cpp/util/create_test_channel.h" -#include "test/core/end2end/data/ssl_test_data.h" -#include #include #include +#include "test/core/end2end/data/ssl_test_data.h" + namespace grpc { // When ssl is enabled, if server is empty, override_hostname is used to diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index 129cc746f9..1263d4ed68 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -36,7 +36,6 @@ #include -#include #include namespace grpc { diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc index 15c56a352c..746d67deeb 100644 --- a/test/cpp/util/grpc_cli.cc +++ b/test/cpp/util/grpc_cli.cc @@ -64,14 +64,13 @@ #include #include -#include "test/cpp/util/cli_call.h" -#include "test/cpp/util/test_config.h" -#include +#include #include #include #include -#include +#include "test/cpp/util/cli_call.h" +#include "test/cpp/util/test_config.h" DEFINE_bool(enable_ssl, true, "Whether to use ssl/tls."); DEFINE_bool(use_auth, false, "Whether to create default google credentials."); diff --git a/test/cpp/util/slice_test.cc b/test/cpp/util/slice_test.cc index eb328490e1..de7ff031ab 100644 --- a/test/cpp/util/slice_test.cc +++ b/test/cpp/util/slice_test.cc @@ -31,7 +31,7 @@ * */ -#include +#include #include #include diff --git a/test/cpp/util/status_test.cc b/test/cpp/util/status_test.cc index 17b92ab06a..837a6bab02 100644 --- a/test/cpp/util/status_test.cc +++ b/test/cpp/util/status_test.cc @@ -31,7 +31,8 @@ * */ -#include +#include + #include #include diff --git a/test/cpp/util/time_test.cc b/test/cpp/util/time_test.cc index 4cb6ec4b4e..1e501dfd28 100644 --- a/test/cpp/util/time_test.cc +++ b/test/cpp/util/time_test.cc @@ -32,7 +32,7 @@ */ #include -#include +#include #include using std::chrono::duration_cast; diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 8daeb134f7..ccea4f68de 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -760,21 +760,13 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -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 \ +INPUT = include/grpc++/channel.h \ include/grpc++/client_context.h \ include/grpc++/completion_queue.h \ -include/grpc++/config.h \ -include/grpc++/config_protobuf.h \ include/grpc++/create_channel.h \ include/grpc++/credentials.h \ -include/grpc++/dynamic_thread_pool.h \ -include/grpc++/fixed_size_thread_pool.h \ -include/grpc++/generic_stub.h \ +include/grpc++/generic/async_generic_service.h \ +include/grpc++/generic/generic_stub.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ include/grpc++/impl/grpc_library.h \ @@ -793,13 +785,21 @@ include/grpc++/server.h \ include/grpc++/server_builder.h \ include/grpc++/server_context.h \ include/grpc++/server_credentials.h \ -include/grpc++/slice.h \ -include/grpc++/status.h \ -include/grpc++/status_code_enum.h \ -include/grpc++/stream.h \ -include/grpc++/stub_options.h \ -include/grpc++/thread_pool_interface.h \ -include/grpc++/time.h +include/grpc++/support/async_unary_call.h \ +include/grpc++/support/auth_context.h \ +include/grpc++/support/byte_buffer.h \ +include/grpc++/support/channel_arguments.h \ +include/grpc++/support/config.h \ +include/grpc++/support/config_protobuf.h \ +include/grpc++/support/dynamic_thread_pool.h \ +include/grpc++/support/fixed_size_thread_pool.h \ +include/grpc++/support/slice.h \ +include/grpc++/support/status.h \ +include/grpc++/support/status_code_enum.h \ +include/grpc++/support/stream.h \ +include/grpc++/support/stub_options.h \ +include/grpc++/support/thread_pool_interface.h \ +include/grpc++/support/time.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 23ff05fb86..c4a7fb0757 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -760,21 +760,13 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -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 \ +INPUT = include/grpc++/channel.h \ include/grpc++/client_context.h \ include/grpc++/completion_queue.h \ -include/grpc++/config.h \ -include/grpc++/config_protobuf.h \ include/grpc++/create_channel.h \ include/grpc++/credentials.h \ -include/grpc++/dynamic_thread_pool.h \ -include/grpc++/fixed_size_thread_pool.h \ -include/grpc++/generic_stub.h \ +include/grpc++/generic/async_generic_service.h \ +include/grpc++/generic/generic_stub.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ include/grpc++/impl/grpc_library.h \ @@ -793,13 +785,21 @@ include/grpc++/server.h \ include/grpc++/server_builder.h \ include/grpc++/server_context.h \ include/grpc++/server_credentials.h \ -include/grpc++/slice.h \ -include/grpc++/status.h \ -include/grpc++/status_code_enum.h \ -include/grpc++/stream.h \ -include/grpc++/stub_options.h \ -include/grpc++/thread_pool_interface.h \ -include/grpc++/time.h \ +include/grpc++/support/async_unary_call.h \ +include/grpc++/support/auth_context.h \ +include/grpc++/support/byte_buffer.h \ +include/grpc++/support/channel_arguments.h \ +include/grpc++/support/config.h \ +include/grpc++/support/config_protobuf.h \ +include/grpc++/support/dynamic_thread_pool.h \ +include/grpc++/support/fixed_size_thread_pool.h \ +include/grpc++/support/slice.h \ +include/grpc++/support/status.h \ +include/grpc++/support/status_code_enum.h \ +include/grpc++/support/stream.h \ +include/grpc++/support/stub_options.h \ +include/grpc++/support/thread_pool_interface.h \ +include/grpc++/support/time.h \ src/cpp/client/secure_credentials.h \ src/cpp/common/secure_auth_context.h \ src/cpp/server/secure_server_credentials.h \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 9446368a8e..8e6afe87d2 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -13118,21 +13118,13 @@ "grpc" ], "headers": [ - "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++/client_context.h", "include/grpc++/completion_queue.h", - "include/grpc++/config.h", - "include/grpc++/config_protobuf.h", "include/grpc++/create_channel.h", "include/grpc++/credentials.h", - "include/grpc++/dynamic_thread_pool.h", - "include/grpc++/fixed_size_thread_pool.h", - "include/grpc++/generic_stub.h", + "include/grpc++/generic/async_generic_service.h", + "include/grpc++/generic/generic_stub.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/grpc_library.h", @@ -13151,13 +13143,21 @@ "include/grpc++/server_builder.h", "include/grpc++/server_context.h", "include/grpc++/server_credentials.h", - "include/grpc++/slice.h", - "include/grpc++/status.h", - "include/grpc++/status_code_enum.h", - "include/grpc++/stream.h", - "include/grpc++/stub_options.h", - "include/grpc++/thread_pool_interface.h", - "include/grpc++/time.h", + "include/grpc++/support/async_unary_call.h", + "include/grpc++/support/auth_context.h", + "include/grpc++/support/byte_buffer.h", + "include/grpc++/support/channel_arguments.h", + "include/grpc++/support/config.h", + "include/grpc++/support/config_protobuf.h", + "include/grpc++/support/dynamic_thread_pool.h", + "include/grpc++/support/fixed_size_thread_pool.h", + "include/grpc++/support/slice.h", + "include/grpc++/support/status.h", + "include/grpc++/support/status_code_enum.h", + "include/grpc++/support/stream.h", + "include/grpc++/support/stub_options.h", + "include/grpc++/support/thread_pool_interface.h", + "include/grpc++/support/time.h", "src/cpp/client/create_channel_internal.h", "src/cpp/client/secure_credentials.h", "src/cpp/common/create_auth_context.h", @@ -13167,21 +13167,13 @@ "language": "c++", "name": "grpc++", "src": [ - "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++/client_context.h", "include/grpc++/completion_queue.h", - "include/grpc++/config.h", - "include/grpc++/config_protobuf.h", "include/grpc++/create_channel.h", "include/grpc++/credentials.h", - "include/grpc++/dynamic_thread_pool.h", - "include/grpc++/fixed_size_thread_pool.h", - "include/grpc++/generic_stub.h", + "include/grpc++/generic/async_generic_service.h", + "include/grpc++/generic/generic_stub.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/grpc_library.h", @@ -13200,13 +13192,21 @@ "include/grpc++/server_builder.h", "include/grpc++/server_context.h", "include/grpc++/server_credentials.h", - "include/grpc++/slice.h", - "include/grpc++/status.h", - "include/grpc++/status_code_enum.h", - "include/grpc++/stream.h", - "include/grpc++/stub_options.h", - "include/grpc++/thread_pool_interface.h", - "include/grpc++/time.h", + "include/grpc++/support/async_unary_call.h", + "include/grpc++/support/auth_context.h", + "include/grpc++/support/byte_buffer.h", + "include/grpc++/support/channel_arguments.h", + "include/grpc++/support/config.h", + "include/grpc++/support/config_protobuf.h", + "include/grpc++/support/dynamic_thread_pool.h", + "include/grpc++/support/fixed_size_thread_pool.h", + "include/grpc++/support/slice.h", + "include/grpc++/support/status.h", + "include/grpc++/support/status_code_enum.h", + "include/grpc++/support/stream.h", + "include/grpc++/support/stub_options.h", + "include/grpc++/support/thread_pool_interface.h", + "include/grpc++/support/time.h", "src/cpp/client/channel.cc", "src/cpp/client/channel_arguments.cc", "src/cpp/client/client_context.cc", @@ -13290,21 +13290,13 @@ "grpc_unsecure" ], "headers": [ - "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++/client_context.h", "include/grpc++/completion_queue.h", - "include/grpc++/config.h", - "include/grpc++/config_protobuf.h", "include/grpc++/create_channel.h", "include/grpc++/credentials.h", - "include/grpc++/dynamic_thread_pool.h", - "include/grpc++/fixed_size_thread_pool.h", - "include/grpc++/generic_stub.h", + "include/grpc++/generic/async_generic_service.h", + "include/grpc++/generic/generic_stub.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/grpc_library.h", @@ -13323,34 +13315,34 @@ "include/grpc++/server_builder.h", "include/grpc++/server_context.h", "include/grpc++/server_credentials.h", - "include/grpc++/slice.h", - "include/grpc++/status.h", - "include/grpc++/status_code_enum.h", - "include/grpc++/stream.h", - "include/grpc++/stub_options.h", - "include/grpc++/thread_pool_interface.h", - "include/grpc++/time.h", + "include/grpc++/support/async_unary_call.h", + "include/grpc++/support/auth_context.h", + "include/grpc++/support/byte_buffer.h", + "include/grpc++/support/channel_arguments.h", + "include/grpc++/support/config.h", + "include/grpc++/support/config_protobuf.h", + "include/grpc++/support/dynamic_thread_pool.h", + "include/grpc++/support/fixed_size_thread_pool.h", + "include/grpc++/support/slice.h", + "include/grpc++/support/status.h", + "include/grpc++/support/status_code_enum.h", + "include/grpc++/support/stream.h", + "include/grpc++/support/stub_options.h", + "include/grpc++/support/thread_pool_interface.h", + "include/grpc++/support/time.h", "src/cpp/client/create_channel_internal.h", "src/cpp/common/create_auth_context.h" ], "language": "c++", "name": "grpc++_unsecure", "src": [ - "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++/client_context.h", "include/grpc++/completion_queue.h", - "include/grpc++/config.h", - "include/grpc++/config_protobuf.h", "include/grpc++/create_channel.h", "include/grpc++/credentials.h", - "include/grpc++/dynamic_thread_pool.h", - "include/grpc++/fixed_size_thread_pool.h", - "include/grpc++/generic_stub.h", + "include/grpc++/generic/async_generic_service.h", + "include/grpc++/generic/generic_stub.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/grpc_library.h", @@ -13369,13 +13361,21 @@ "include/grpc++/server_builder.h", "include/grpc++/server_context.h", "include/grpc++/server_credentials.h", - "include/grpc++/slice.h", - "include/grpc++/status.h", - "include/grpc++/status_code_enum.h", - "include/grpc++/stream.h", - "include/grpc++/stub_options.h", - "include/grpc++/thread_pool_interface.h", - "include/grpc++/time.h", + "include/grpc++/support/async_unary_call.h", + "include/grpc++/support/auth_context.h", + "include/grpc++/support/byte_buffer.h", + "include/grpc++/support/channel_arguments.h", + "include/grpc++/support/config.h", + "include/grpc++/support/config_protobuf.h", + "include/grpc++/support/dynamic_thread_pool.h", + "include/grpc++/support/fixed_size_thread_pool.h", + "include/grpc++/support/slice.h", + "include/grpc++/support/status.h", + "include/grpc++/support/status_code_enum.h", + "include/grpc++/support/stream.h", + "include/grpc++/support/stub_options.h", + "include/grpc++/support/thread_pool_interface.h", + "include/grpc++/support/time.h", "src/cpp/client/channel.cc", "src/cpp/client/channel_arguments.cc", "src/cpp/client/client_context.cc", diff --git a/vsprojects/grpc++/grpc++.vcxproj b/vsprojects/grpc++/grpc++.vcxproj index e2e17d4177..5181b3a200 100644 --- a/vsprojects/grpc++/grpc++.vcxproj +++ b/vsprojects/grpc++/grpc++.vcxproj @@ -213,21 +213,13 @@ - - - - - - - - - - + + @@ -246,13 +238,21 @@ - - - - - - - + + + + + + + + + + + + + + + diff --git a/vsprojects/grpc++/grpc++.vcxproj.filters b/vsprojects/grpc++/grpc++.vcxproj.filters index 6f308d1d02..cbffd3c765 100644 --- a/vsprojects/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/grpc++/grpc++.vcxproj.filters @@ -96,50 +96,26 @@ - - include\grpc++ - - - include\grpc++ - - - include\grpc++ - - - include\grpc++ - include\grpc++ - - include\grpc++ - include\grpc++ include\grpc++ - - include\grpc++ - - - include\grpc++ - include\grpc++ include\grpc++ - - include\grpc++ - - - include\grpc++ + + include\grpc++\generic - - include\grpc++ + + include\grpc++\generic include\grpc++\impl @@ -195,26 +171,50 @@ include\grpc++ - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support @@ -242,9 +242,15 @@ {784a0281-f547-aeb0-9f55-b26b7de9c769} + + {51dae921-3aa2-1976-2ee4-c5615de1af54} + {0da8cd95-314f-da1b-5ce7-7791a5be1f1a} + + {a5c10dae-f715-2a30-1066-d22f8bc94cb2} + {328ff211-2886-406e-56f9-18ba1686f363} diff --git a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj index 4be468cb62..77f83086c7 100644 --- a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -213,21 +213,13 @@ - - - - - - - - - - + + @@ -246,13 +238,21 @@ - - - - - - - + + + + + + + + + + + + + + + diff --git a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index bd51d1fa0b..d4288f8987 100644 --- a/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -81,50 +81,26 @@ - - include\grpc++ - - - include\grpc++ - - - include\grpc++ - - - include\grpc++ - include\grpc++ - - include\grpc++ - include\grpc++ include\grpc++ - - include\grpc++ - - - include\grpc++ - include\grpc++ include\grpc++ - - include\grpc++ - - - include\grpc++ + + include\grpc++\generic - - include\grpc++ + + include\grpc++\generic include\grpc++\impl @@ -180,26 +156,50 @@ include\grpc++ - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support - - include\grpc++ + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support + + + include\grpc++\support @@ -218,9 +218,15 @@ {eceb50c0-bb49-3812-b6bd-b0af6df81da7} + + {83717d3c-57d9-2bfa-ed9c-2b08f86da12b} + {dadc0002-f2ac-451b-a9b8-33b8de10b5fc} + + {0ebf8008-80b9-d6da-e1dc-854bf1ec2195} + {cce6a85d-1111-3834-6825-31e170d93cff} -- cgit v1.2.3