aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar makdharma <makdharma@users.noreply.github.com>2016-09-08 08:19:10 -0700
committerGravatar GitHub <noreply@github.com>2016-09-08 08:19:10 -0700
commit93b09478f0264f62e577b215dea7bc908abc6b98 (patch)
treeef3540e7165412fb69e9ae88bb881e22ec0e2d64
parent47b2961638328d29577361c3cb4dec5ab5bab537 (diff)
parent2b98b77225f40c0a3317586f7e28ae1b22afa403 (diff)
Merge pull request #8024 from makdharma/cpp_cacheable
add cacheable option to client_context
-rw-r--r--include/grpc++/impl/codegen/client_context.h7
-rw-r--r--src/cpp/client/client_context.cc1
2 files changed, 7 insertions, 1 deletions
diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h
index d77ca4c396..9fecb5043e 100644
--- a/include/grpc++/impl/codegen/client_context.h
+++ b/include/grpc++/impl/codegen/client_context.h
@@ -225,6 +225,9 @@ class ClientContext {
/// EXPERIMENTAL: Set this request to be idempotent
void set_idempotent(bool idempotent) { idempotent_ = idempotent; }
+ /// EXPERIMENTAL: Set this request to be cacheable
+ void set_cacheable(bool cacheable) { cacheable_ = cacheable; }
+
/// EXPERIMENTAL: Trigger fail-fast or not on this request
void set_fail_fast(bool fail_fast) { fail_fast_ = fail_fast; }
@@ -346,7 +349,8 @@ class ClientContext {
uint32_t initial_metadata_flags() const {
return (idempotent_ ? GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST : 0) |
- (fail_fast_ ? 0 : GRPC_INITIAL_METADATA_IGNORE_CONNECTIVITY);
+ (fail_fast_ ? 0 : GRPC_INITIAL_METADATA_IGNORE_CONNECTIVITY) |
+ (cacheable_ ? GRPC_INITIAL_METADATA_CACHEABLE_REQUEST : 0);
}
grpc::string authority() { return authority_; }
@@ -354,6 +358,7 @@ class ClientContext {
bool initial_metadata_received_;
bool fail_fast_;
bool idempotent_;
+ bool cacheable_;
std::shared_ptr<Channel> channel_;
grpc::mutex mu_;
grpc_call* call_;
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index 0ba77a5057..74bb7b0d1c 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -60,6 +60,7 @@ ClientContext::ClientContext()
: initial_metadata_received_(false),
fail_fast_(true),
idempotent_(false),
+ cacheable_(false),
call_(nullptr),
call_canceled_(false),
deadline_(gpr_inf_future(GPR_CLOCK_REALTIME)),