1
#pragma once
2

            
3
#include <memory>
4

            
5
#include "envoy/common/pure.h"
6

            
7
#include "absl/strings/string_view.h"
8
#include "absl/types/optional.h"
9

            
10
namespace Envoy {
11
namespace StreamInfo {
12

            
13
/**
14
 * Stream id for a stream (TCP connection, long-live HTTP2
15
 * stream, HTTP request, etc.). This  provides string view
16
 * for logging and tracing and integer view for in modulo,
17
 * etc. calculations.
18
 */
19
class StreamIdProvider {
20
public:
21
98397
  virtual ~StreamIdProvider() = default;
22

            
23
  /**
24
   * @return the optional string view of the stream id.
25
   */
26
  virtual absl::optional<absl::string_view> toStringView() const PURE;
27

            
28
  /**
29
   * @return the optional integer view of the stream id.
30
   */
31
  virtual absl::optional<uint64_t> toInteger() const PURE;
32
};
33
using StreamIdProviderSharedPtr = std::shared_ptr<StreamIdProvider>;
34

            
35
} // namespace StreamInfo
36
} // namespace Envoy