userver: userver/server/congestion_control/limiter.hpp Source File
Loading...
Searching...
No Matches
limiter.hpp
1#pragma once
2
3#include <optional>
4#include <vector>
5
6#include <userver/concurrent/variable.hpp>
7#include <userver/congestion_control/limiter.hpp>
8#include <userver/utils/not_null.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace server::congestion_control {
13
14class Limitee {
15 public:
16 virtual void SetLimit(std::optional<size_t> new_limit) = 0;
17};
18
19class Limiter final : public USERVER_NAMESPACE::congestion_control::Limiter {
20 public:
21 void SetLimit(
22 const USERVER_NAMESPACE::congestion_control::Limit& new_limit) override;
23
24 void RegisterLimitee(Limitee& limitee);
25
26 private:
27 concurrent::Variable<std::vector<utils::NotNull<Limitee*>>, std::mutex>
28 limitees_;
29};
30
31} // namespace server::congestion_control
32
33USERVER_NAMESPACE_END