1
#pragma once
2

            
3
#include "envoy/network/connection.h"
4

            
5
#include "absl/types/optional.h"
6

            
7
namespace Envoy {
8
namespace Network {
9
/**
10
 * Hash policy for transport layer protocol.
11
 */
12
class HashPolicy {
13
public:
14
4
  virtual ~HashPolicy() = default;
15

            
16
  /**
17
   * @param connection is the raw downstream connection. Different implementations of HashPolicy can
18
   *        compute hashes based on different data accessible from the connection (e.g. IP address,
19
   *        filter state, etc.).
20
   * @return absl::optional<uint64_t> an optional hash value to route on. A hash value might not be
21
   * returned if the hash policy implementation doesn't find the expected data in the connection
22
   * (e.g. IP address is null, filter state is not populated, etc.).
23
   */
24
  virtual absl::optional<uint64_t> generateHash(const Network::Connection& connection) const PURE;
25
};
26
} // namespace Network
27
} // namespace Envoy