1
#pragma once
2

            
3
#include "envoy/network/connection.h"
4
#include "envoy/network/hash_policy.h"
5
#include "envoy/type/v3/hash_policy.pb.h"
6

            
7
#include "source/common/common/hash.h"
8

            
9
namespace Envoy {
10
namespace Network {
11
/**
12
 * Implementation of HashPolicy that reads from the proto TCP proxy config.
13
 */
14
class HashPolicyImpl : public Network::HashPolicy {
15
public:
16
  explicit HashPolicyImpl(const absl::Span<const envoy::type::v3::HashPolicy* const>& hash_policy);
17

            
18
  // Network::HashPolicy
19
  absl::optional<uint64_t> generateHash(const Network::Connection& connection) const override;
20

            
21
  class HashMethod {
22
  public:
23
4
    virtual ~HashMethod() = default;
24
    virtual absl::optional<uint64_t> evaluate(const Network::Connection& connection) const PURE;
25
  };
26

            
27
  using HashMethodPtr = std::unique_ptr<HashMethod>;
28

            
29
private:
30
  HashMethodPtr hash_impl_;
31
};
32
} // namespace Network
33
} // namespace Envoy