shaping: use LimitSpec for provider_connection_limit

This commit is contained in:
Wez Furlong
2025-01-07 06:47:36 -07:00
parent c65c7aec64
commit 2d753232cf
2 changed files with 10 additions and 2 deletions
+4 -2
View File
@@ -27,6 +27,8 @@ use std::marker::PhantomData;
#[cfg(feature = "lua")]
use std::sync::Arc;
use std::time::Duration;
#[cfg(feature = "lua")]
use throttle::LimitSpec;
use throttle::ThrottleSpec;
#[derive(Deserialize, Serialize, Debug, Clone)]
@@ -1011,7 +1013,7 @@ pub struct ProviderEntry {
pub provider_name: String,
#[serde(default)]
pub provider_connection_limit: Option<usize>,
pub provider_connection_limit: Option<LimitSpec>,
#[serde(default)]
pub provider_max_message_rate: Option<ThrottleSpec>,
@@ -1197,7 +1199,7 @@ impl ProviderEntry {
let mut limits = toml::Table::new();
limits.insert(
format!("shaping-provider-{}-{source}-limit", self.provider_name),
toml::Value::Integer((*limit) as i64),
toml::Value::String(limit.to_string()),
);
implied.insert(
"additional_connection_limits".to_string(),
+6
View File
@@ -246,6 +246,12 @@ impl std::fmt::Debug for LimitSpec {
}
}
impl std::fmt::Display for LimitSpec {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(fmt, "{:?}", self)
}
}
impl LimitSpec {
pub const fn new(limit: u64) -> Self {
Self {