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
2
      : metadata_match_criteria_(metadata_match_criteria) {
17
2
    const auto& filter_it = metadata_match_criteria_.filter_metadata().find(
18
2
        Envoy::Config::MetadataFilters::get().ENVOY_LB);
19
2
    if (filter_it != metadata_match_criteria_.filter_metadata().end()) {
20
1
      for (auto const& it : filter_it->second.fields()) {
21
1
        label_set_.push_back(it);
22
1
      }
23
1
    }
24
2
  }
25

            
26
  bool shouldSelectAnotherHost(const Upstream::Host& host) override;
27

            
28
1
  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, Protobuf::Value>> label_set_;
33
};
34

            
35
} // namespace Host
36
} // namespace Retry
37
} // namespace Extensions
38
} // namespace Envoy