Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-adds generate #742

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions lading_payload/src/dogstatsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ pub struct KindWeights {
service_check: u8,
}

impl KindWeights {
/// Create a new instance of `KindWeights` according to the args
pub fn new(metric: u8, event: u8, service_check: u8) -> Self {
Self {
metric,
event,
service_check,
}
}
}

impl Default for KindWeights {
fn default() -> Self {
KindWeights {
Expand All @@ -115,6 +126,20 @@ pub struct MetricWeights {
histogram: u8,
}

impl MetricWeights {
/// Create a new instance of `MetricWeights` according to the args
pub fn new(count: u8, gauge: u8, timer: u8, distribution: u8, set: u8, histogram: u8) -> Self {
Self {
count,
gauge,
timer,
distribution,
set,
histogram,
}
}
}

impl Default for MetricWeights {
fn default() -> Self {
MetricWeights {
Expand Down Expand Up @@ -544,6 +569,16 @@ impl DogStatsD {
.unwrap()
}

/// Generate a single `Member`.
/// Prefer using the Serialize implementation for `DogStatsD` which
/// generates a stream of `Member`s according to some constraints.
pub fn generate<R>(&self, rng: &mut R) -> Member
where
R: rand::Rng + ?Sized,
{
self.member_generator.generate(rng)
}

/// Create a new instance of `DogStatsD`.
///
/// # Errors
Expand Down
Loading