1
#pragma once
2

            
3
#include <list>
4

            
5
#include "source/extensions/config_subscription/grpc/update_ack.h"
6

            
7
#include "absl/container/flat_hash_map.h"
8

            
9
namespace Envoy {
10
namespace Config {
11

            
12
// There is a head-of-line blocking issue resulting from the intersection of 1) ADS's need for
13
// subscription request ordering and 2) the ability to "pause" one of the resource types within ADS.
14
// We need a queue that understands ADS's resource type pausing. Specifically, we need front()/pop()
15
// to choose the first element whose type_url isn't paused.
16
class PausableAckQueue {
17
public:
18
  void push(UpdateAck x);
19
  size_t size() const;
20
  bool empty();
21
  const UpdateAck& front();
22
  UpdateAck popFront();
23
  void pause(const std::string& type_url);
24
  void resume(const std::string& type_url);
25
  bool paused(const std::string& type_url) const;
26
  void clear();
27

            
28
private:
29
  // It's ok for non-existent subs to be paused/resumed. The cleanest way to support that is to give
30
  // the pause state its own map. (Map key is type_url.)
31
  absl::flat_hash_map<std::string, uint32_t> pauses_;
32
  std::list<UpdateAck> storage_;
33
};
34

            
35
} // namespace Config
36
} // namespace Envoy