diff options
author | yang-g <yangg@google.com> | 2015-08-06 22:51:27 -0700 |
---|---|---|
committer | yang-g <yangg@google.com> | 2015-08-06 22:51:27 -0700 |
commit | 87e133e13ae06ef5d1752cf37a473896ddf555cb (patch) | |
tree | 5bb0c0ef8221fb51914e7c146751280f4f5ef7df /include/grpc++ | |
parent | c8abca8f5311832f41751ab11bb2365f9e348ad8 (diff) | |
parent | 03b19118e349ca480f2739ed6efd00ba7be4cf45 (diff) |
merge with head
Diffstat (limited to 'include/grpc++')
-rw-r--r-- | include/grpc++/client_context.h | 62 | ||||
-rw-r--r-- | include/grpc++/server_context.h | 2 | ||||
-rw-r--r-- | include/grpc++/stream.h | 6 | ||||
-rw-r--r-- | include/grpc++/stub_options.h | 43 |
4 files changed, 110 insertions, 3 deletions
diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h index 10c967d85b..34945f3282 100644 --- a/include/grpc++/client_context.h +++ b/include/grpc++/client_context.h @@ -39,6 +39,7 @@ #include <string> #include <grpc/compression.h> +#include <grpc/grpc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> #include <grpc++/auth_context.h> @@ -46,8 +47,6 @@ #include <grpc++/status.h> #include <grpc++/time.h> -struct grpc_call; -struct grpc_completion_queue; struct census_context; namespace grpc { @@ -70,12 +69,68 @@ template <class R, class W> class ClientAsyncReaderWriter; template <class R> class ClientAsyncResponseReader; +class ServerContext; + +class PropagationOptions { + public: + PropagationOptions() : propagate_(GRPC_PROPAGATE_DEFAULTS) {} + + PropagationOptions& enable_deadline_propagation() { + propagate_ |= GRPC_PROPAGATE_DEADLINE; + return *this; + } + + PropagationOptions& disable_deadline_propagation() { + propagate_ &= ~GRPC_PROPAGATE_DEADLINE; + return *this; + } + + PropagationOptions& enable_census_stats_propagation() { + propagate_ |= GRPC_PROPAGATE_CENSUS_STATS_CONTEXT; + return *this; + } + + PropagationOptions& disable_census_stats_propagation() { + propagate_ &= ~GRPC_PROPAGATE_CENSUS_STATS_CONTEXT; + return *this; + } + + PropagationOptions& enable_census_tracing_propagation() { + propagate_ |= GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT; + return *this; + } + + PropagationOptions& disable_census_tracing_propagation() { + propagate_ &= ~GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT; + return *this; + } + + PropagationOptions& enable_cancellation_propagation() { + propagate_ |= GRPC_PROPAGATE_CANCELLATION; + return *this; + } + + PropagationOptions& disable_cancellation_propagation() { + propagate_ &= ~GRPC_PROPAGATE_CANCELLATION; + return *this; + } + + gpr_uint32 c_bitmask() const { return propagate_; } + + private: + gpr_uint32 propagate_; +}; class ClientContext { public: ClientContext(); ~ClientContext(); + /// Create a new ClientContext that propagates some or all of its attributes + static std::unique_ptr<ClientContext> FromServerContext( + const ServerContext& server_context, + PropagationOptions options = PropagationOptions()); + void AddMetadata(const grpc::string& meta_key, const grpc::string& meta_value); @@ -181,6 +236,9 @@ class ClientContext { std::multimap<grpc::string, grpc::string> recv_initial_metadata_; std::multimap<grpc::string, grpc::string> trailing_metadata_; + grpc_call* propagate_from_call_; + PropagationOptions propagation_options_; + grpc_compression_algorithm compression_algorithm_; }; diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h index 23273f43e6..4f7fc54ef1 100644 --- a/include/grpc++/server_context.h +++ b/include/grpc++/server_context.h @@ -50,6 +50,7 @@ struct census_context; namespace grpc { +class ClientContext; template <class W, class R> class ServerAsyncReader; template <class W> @@ -158,6 +159,7 @@ class ServerContext { friend class ServerStreamingHandler; template <class ServiceType, class RequestType, class ResponseType> friend class BidiStreamingHandler; + friend class ::grpc::ClientContext; // Prevent copying. ServerContext(const ServerContext&); diff --git a/include/grpc++/stream.h b/include/grpc++/stream.h index 3903f2ec06..bc0c3c0f3b 100644 --- a/include/grpc++/stream.h +++ b/include/grpc++/stream.h @@ -54,7 +54,11 @@ class ClientStreamingInterface { // 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(). Otherwise, this implicitly cancels the stream. + // 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; }; diff --git a/include/grpc++/stub_options.h b/include/grpc++/stub_options.h new file mode 100644 index 0000000000..c7c16dcd55 --- /dev/null +++ b/include/grpc++/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_STUB_OPTIONS_H +#define GRPCXX_STUB_OPTIONS_H + +namespace grpc { + +class StubOptions {}; + +} // namespace grpc + +#endif // GRPCXX_STUB_OPTIONS_H |