Skip to content

Commit

Permalink
Revert "nats: De/Ser using sample_freq instead of sample_frequency"
Browse files Browse the repository at this point in the history
This reverts commit f2b24ca.
  • Loading branch information
Benjamin Sparks committed Aug 19, 2024
1 parent f2b24ca commit f602c58
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions nats/src/jetstream/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,7 @@ pub struct ConsumerConfig {
#[serde(default, skip_serializing_if = "is_default")]
pub rate_limit: u64,
/// What percentage of acknowledgments should be samples for observability, 0-100
#[serde(
rename = "sample_freq",
with = "from_str",
default,
skip_serializing_if = "is_default"
)]
#[serde(default, skip_serializing_if = "is_default")]
pub sample_frequency: u8,
/// The maximum number of waiting consumers.
#[serde(default, skip_serializing_if = "is_default")]
Expand Down Expand Up @@ -259,26 +254,6 @@ pub struct ConsumerConfig {
pub inactive_threshold: Duration,
}

mod from_str {
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
where
T: std::str::FromStr,
T::Err: std::fmt::Display,
D: serde::Deserializer<'de>,
{
let s = <String as serde::Deserialize>::deserialize(deserializer)?;
T::from_str(&s).map_err(serde::de::Error::custom)
}

pub fn serialize<T, S>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
where
T: std::fmt::Display,
S: serde::Serializer,
{
serializer.serialize_str(&value.to_string())
}
}

pub(crate) enum ConsumerKind {
Pull,
}
Expand Down

0 comments on commit f602c58

Please sign in to comment.