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() {
15 return "limit=" +
16 (load_limit ? std::to_string(*load_limit) : std::string("(none)"));
17 }
18};
19
20class Limiter {
21 public:
22 virtual void SetLimit(const Limit& new_limit) = 0;
23
24 protected:
25 ~Limiter() = default;
26};
27
28} // namespace congestion_control
29
30USERVER_NAMESPACE_END