Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/upstream/retry.h" 4 : #include "envoy/upstream/upstream.h" 5 : 6 : #include "source/common/config/well_known_names.h" 7 : 8 : namespace Envoy { 9 : namespace Extensions { 10 : namespace Retry { 11 : namespace Host { 12 : 13 : class OmitHostsRetryPredicate : public Upstream::RetryHostPredicate { 14 : public: 15 : explicit OmitHostsRetryPredicate(const envoy::config::core::v3::Metadata& metadata_match_criteria) 16 0 : : metadata_match_criteria_(metadata_match_criteria) { 17 0 : const auto& filter_it = metadata_match_criteria_.filter_metadata().find( 18 0 : Envoy::Config::MetadataFilters::get().ENVOY_LB); 19 0 : if (filter_it != metadata_match_criteria_.filter_metadata().end()) { 20 0 : for (auto const& it : filter_it->second.fields()) { 21 0 : label_set_.push_back(it); 22 0 : } 23 0 : } 24 0 : } 25 : 26 : bool shouldSelectAnotherHost(const Upstream::Host& host) override; 27 : 28 0 : void onHostAttempted(Upstream::HostDescriptionConstSharedPtr) override {} 29 : 30 : private: 31 : const envoy::config::core::v3::Metadata metadata_match_criteria_; 32 : std::vector<std::pair<std::string, ProtobufWkt::Value>> label_set_; 33 : }; 34 : 35 : } // namespace Host 36 : } // namespace Retry 37 : } // namespace Extensions 38 : } // namespace Envoy