mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-11-10 21:22:20 +03:00
Summary: This is a very simple rate limiter that allows us to very cheaply limit things like Initials per server per window. See the comment in SlidingWindowRateLimiter.h for a description of how it functions. Reviewed By: sharmafb Differential Revision: D20311019 fbshipit-source-id: e0b4fddd467252c43b63ae21dfd3d0284b7926e7
29 lines
525 B
C++
29 lines
525 B
C++
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include <chrono>
|
|
|
|
#include <quic/QuicConstants.h>
|
|
|
|
namespace quic {
|
|
|
|
/*
|
|
* Basic rate limiter interface that is driven solely by a monotonically
|
|
* clocked events.
|
|
*/
|
|
class RateLimiter {
|
|
public:
|
|
RateLimiter() = default;
|
|
|
|
virtual ~RateLimiter() = default;
|
|
|
|
/*
|
|
* Check if an event at a certain time should be rate limited. Returns true
|
|
* if it should be rate limited.
|
|
*/
|
|
virtual bool check(TimePoint time) = 0;
|
|
};
|
|
|
|
} // namespace quic
|