userver: userver/congestion_control/limiter.hpp Source File
Loading...
Searching...
No Matches
limiter.hpp
1#pragma once
2
3#include <optional>
4#include <string>
5
6USERVER_NAMESPACE_BEGIN
7
8namespace congestion_control {
9
10struct Limit {
11 std::optional<size_t> load_limit;
12 size_t current_load{0};
13
14 std::string ToLogString() { return "limit=" + (load_limit ? std::to_string(*load_limit) : std::string("(none)")); }
15};
16
17class Limiter {
18public:
19 virtual void SetLimit(const Limit& new_limit) = 0;
20
21protected:
22 ~Limiter() = default;
23};
24
25} // namespace congestion_control
26
27USERVER_NAMESPACE_END