Coverage Report

Created: 2024-09-19 09:45

/proc/self/cwd/test/integration/test_host_predicate.h
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include "envoy/upstream/retry.h"
4
5
namespace Envoy {
6
7
/**
8
 * A simple host predicate that will remember the first host it sees and reject
9
 * all other hosts.
10
 */
11
class TestHostPredicate : public Upstream::RetryHostPredicate {
12
0
  bool shouldSelectAnotherHost(const Upstream::Host& candidate_host) override {
13
0
    return !first_host_address_ || *first_host_address_ != candidate_host.address()->asString();
14
0
  }
15
16
0
  void onHostAttempted(Upstream::HostDescriptionConstSharedPtr attempted_host) override {
17
0
    if (!first_host_address_) {
18
0
      first_host_address_ = attempted_host->address()->asString();
19
0
    }
20
0
  }
21
22
  absl::optional<std::string> first_host_address_;
23
};
24
} // namespace Envoy