Skip to content

Commit

Permalink
Use best_effort for prefetch. (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiwzhang authored Apr 25, 2017
1 parent 3b6a587 commit 120b577
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions mixerclient/src/quota_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ QuotaCache::QuotaCache(const QuotaOptions& options, QuotaTransport* transport)

// Excluse quota_amount in the key calculation.
cache_keys_ = CacheKeySet::CreateExclusive({Attributes::kQuotaAmount});

if (transport_ != nullptr) {
transport_->set_best_effort(true);
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions mixerclient/src/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ typedef Transport<::istio::mixer::v1::QuotaRequest,
class QuotaTransport : public QuotaBaseTransport {
public:
QuotaTransport(TransportInterface* transport)
: QuotaBaseTransport(transport), deduplication_id_(0) {}
: QuotaBaseTransport(transport),
best_effort_(false),
deduplication_id_(0) {}

void set_best_effort(bool v) { best_effort_ = v; }

private:
void FillProto(StreamID stream_id, const Attributes& attributes,
Expand All @@ -98,11 +102,12 @@ class QuotaTransport : public QuotaBaseTransport {
}
}
request->set_deduplication_id(std::to_string(deduplication_id_++));
request->set_best_effort(false);
request->set_best_effort(best_effort_);

QuotaBaseTransport::FillProto(stream_id, filtered_attributes, request);
}

bool best_effort_;
int64_t deduplication_id_;
};

Expand Down

0 comments on commit 120b577

Please sign in to comment.