diff options
author | David Garcia Quintas <dgq@google.com> | 2015-08-09 09:21:01 -0700 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2015-08-09 09:21:01 -0700 |
commit | 49a513031880a6303273f3fe3cec837225a5ad78 (patch) | |
tree | 0140ee377eb87732cdb6072576751d98f8c9d8cc /include/grpc++/client_context.h | |
parent | 7c0d914cce379f14a1adfae9374641967c45d7b2 (diff) | |
parent | 10494fcb61d638682fb8e5d28356a1f5125e8d0a (diff) |
Merge branch 'compression-accept-encoding' into compression-interop
Diffstat (limited to 'include/grpc++/client_context.h')
-rw-r--r-- | include/grpc++/client_context.h | 76 |
1 files changed, 70 insertions, 6 deletions
diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h index ccaf582d0a..5137bf6a1a 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,6 +69,57 @@ 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_; +}; namespace testing { class InteropClientContextInspector; @@ -80,6 +130,11 @@ class ClientContext { 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); @@ -114,7 +169,7 @@ class ClientContext { creds_ = creds; } - grpc_compression_algorithm get_compression_algorithm() const { + grpc_compression_algorithm compression_algorithm() const { return compression_algorithm_; } @@ -122,9 +177,15 @@ class ClientContext { std::shared_ptr<const AuthContext> auth_context() const; + // Return the peer uri in a string. + // WARNING: this value is never authenticated or subject to any security + // related code. It must not be used for any authentication related + // functionality. Instead, use auth_context. + grpc::string peer() const; + // Get and set census context - void set_census_context(census_context* ccp) { census_context_ = ccp; } - census_context* get_census_context() const { return census_context_; } + void set_census_context(struct census_context* ccp) { census_context_ = ccp; } + struct census_context* census_context() const { return census_context_; } void TryCancel(); @@ -175,11 +236,14 @@ class ClientContext { grpc::string authority_; std::shared_ptr<Credentials> creds_; mutable std::shared_ptr<const AuthContext> auth_context_; - census_context* census_context_; + struct census_context* census_context_; std::multimap<grpc::string, grpc::string> send_initial_metadata_; 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_; }; |