move src/shared_rate_limiter.rs to src/tools/shared_rate_limiter.rs
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
260147bd73
commit
d6644e29fe
|
@ -33,9 +33,6 @@ pub mod client_helpers;
|
||||||
|
|
||||||
pub mod rrd_cache;
|
pub mod rrd_cache;
|
||||||
|
|
||||||
mod shared_rate_limiter;
|
|
||||||
pub use shared_rate_limiter::SharedRateLimiter;
|
|
||||||
|
|
||||||
pub mod traffic_control_cache;
|
pub mod traffic_control_cache;
|
||||||
|
|
||||||
/// Get the server's certificate info (from `proxy.pem`).
|
/// Get the server's certificate info (from `proxy.pem`).
|
||||||
|
|
|
@ -16,6 +16,9 @@ pub mod apt;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod disks;
|
pub mod disks;
|
||||||
|
|
||||||
|
mod shared_rate_limiter;
|
||||||
|
pub use shared_rate_limiter::SharedRateLimiter;
|
||||||
|
|
||||||
pub mod statistics;
|
pub mod statistics;
|
||||||
pub mod subscription;
|
pub mod subscription;
|
||||||
pub mod systemd;
|
pub mod systemd;
|
||||||
|
|
|
@ -55,12 +55,21 @@ impl Init for SharedRateLimiterData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Rate limiter designed for shared memory ([SharedMemory])
|
||||||
|
///
|
||||||
|
/// The actual [RateLimiter] is protected by a [SharedMutex] and
|
||||||
|
/// implements [Init]. This way we can share the limiter between
|
||||||
|
/// different processes.
|
||||||
pub struct SharedRateLimiter {
|
pub struct SharedRateLimiter {
|
||||||
shmem: SharedMemory<SharedRateLimiterData>
|
shmem: SharedMemory<SharedRateLimiterData>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SharedRateLimiter {
|
impl SharedRateLimiter {
|
||||||
|
|
||||||
|
/// Creates a new mmap'ed instance.
|
||||||
|
///
|
||||||
|
/// Data is mapped in `/var/run/proxmox-backup/shmem/tbf/<name>` using
|
||||||
|
/// `TMPFS`.
|
||||||
pub fn mmap_shmem(name: &str, rate: u64, burst: u64) -> Result<Self, Error> {
|
pub fn mmap_shmem(name: &str, rate: u64, burst: u64) -> Result<Self, Error> {
|
||||||
let mut path = PathBuf::from(BASE_PATH);
|
let mut path = PathBuf::from(BASE_PATH);
|
||||||
|
|
|
@ -18,7 +18,7 @@ use pbs_api_types::TrafficControlRule;
|
||||||
|
|
||||||
use pbs_config::ConfigVersionCache;
|
use pbs_config::ConfigVersionCache;
|
||||||
|
|
||||||
use super::SharedRateLimiter;
|
use crate::tools::SharedRateLimiter;
|
||||||
|
|
||||||
lazy_static::lazy_static!{
|
lazy_static::lazy_static!{
|
||||||
/// Shared traffic control cache singleton.
|
/// Shared traffic control cache singleton.
|
||||||
|
|
Loading…
Reference in New Issue