Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/upstream/retry.h" 4 : #include "envoy/upstream/upstream.h" 5 : 6 : namespace Envoy { 7 : class PreviousHostsRetryPredicate : public Upstream::RetryHostPredicate { 8 : public: 9 0 : bool shouldSelectAnotherHost(const Upstream::Host& candidate_host) override { 10 0 : return std::find(attempted_hosts_.begin(), attempted_hosts_.end(), &candidate_host) != 11 0 : attempted_hosts_.end(); 12 0 : } 13 0 : void onHostAttempted(Upstream::HostDescriptionConstSharedPtr attempted_host) override { 14 0 : attempted_hosts_.emplace_back(attempted_host.get()); 15 0 : } 16 : 17 : private: 18 : std::vector<Upstream::HostDescription const*> attempted_hosts_; 19 : }; 20 : } // namespace Envoy