1
#pragma once
2

            
3
#include <cstdint>
4
#include <memory>
5

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

            
8
namespace Envoy {
9
/**
10
 * Generic interface for all backoff strategy implementations.
11
 */
12
class BackOffStrategy {
13
public:
14
6150
  virtual ~BackOffStrategy() = default;
15

            
16
  /**
17
   * @return the next backoff interval in milli seconds.
18
   */
19
  virtual uint64_t nextBackOffMs() PURE;
20

            
21
  /**
22
   * Resets the intervals so that the back off intervals can start again.
23
   */
24
  virtual void reset() PURE;
25

            
26
  /**
27
   * @return if the time interval exceeds any configured cap on next backoff value.
28
   */
29
  virtual bool isOverTimeLimit(uint64_t interval_ms) const PURE;
30
};
31

            
32
using BackOffStrategyPtr = std::unique_ptr<BackOffStrategy>;
33
} // namespace Envoy