Skip to content

Commit

Permalink
add cacheable option to client_context
Browse files Browse the repository at this point in the history
  • Loading branch information
makdharma committed Sep 7, 2016
1 parent cd0ea63 commit 2b98b77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/grpc++/impl/codegen/client_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -346,14 +349,16 @@ 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_; }

bool initial_metadata_received_;
bool fail_fast_;
bool idempotent_;
bool cacheable_;
std::shared_ptr<Channel> channel_;
grpc::mutex mu_;
grpc_call* call_;
Expand Down
1 change: 1 addition & 0 deletions src/cpp/client/client_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 2b98b77

Please sign in to comment.