1
#pragma once
2

            
3
#include <ostream>
4

            
5
#include "envoy/common/optref.h"
6
#include "envoy/common/pure.h"
7
#include "envoy/stream_info/stream_info.h"
8

            
9
namespace Envoy {
10

            
11
/*
12
 * An interface for tracking the scope of work. Implementors of this interface
13
 * can be registered to the dispatcher when they're active on the stack. If a
14
 * fatal error occurs while they were active, the dumpState() method will be
15
 * called to output the active state.
16
 *
17
 * Currently this is only used for the L4 network connection and L7 stream.
18
 */
19
class ScopeTrackedObject {
20
public:
21
1149898
  virtual ~ScopeTrackedObject() = default;
22

            
23
  /**
24
   * Return the tracked stream info that related to the scope tracked object (L4
25
   * network connection or L7 stream).
26
   * @return optional reference to stream info of stream (L4 connection or L7 stream).
27
   */
28
  virtual OptRef<const StreamInfo::StreamInfo> trackedStream() const { return {}; }
29

            
30
  /**
31
   * Dump debug state of the object in question to the provided ostream.
32
   *
33
   * This is called on Envoy fatal errors, so should do minimal memory allocation.
34
   *
35
   * @param os the ostream to output to.
36
   * @param indent_level how far to indent, for pretty-printed classes and subclasses.
37
   */
38
  virtual void dumpState(std::ostream& os, int indent_level = 0) const PURE;
39
};
40

            
41
} // namespace Envoy