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

chore: update Rust to 1.82.0 #305

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
10 changes: 0 additions & 10 deletions bin/correctness/ground-truth/src/analysis/metric.rs
Original file line number Diff line number Diff line change
@@ -30,11 +30,6 @@ impl NormalizedMetricContext {
pub fn name(&self) -> &str {
&self.name
}

/// Returns the tags of the metric.
pub fn tags(&self) -> &[String] {
&self.tags
}
}

impl fmt::Display for NormalizedMetricContext {
@@ -176,11 +171,6 @@ impl NormalizedMetrics {
Ok(Self { metrics })
}

/// Returns `true` if the set of metrics is empty.
pub fn is_empty(&self) -> bool {
self.metrics.is_empty()
}

/// Returns the number of metrics in the set.
pub fn len(&self) -> usize {
self.metrics.len()
10 changes: 0 additions & 10 deletions bin/correctness/ground-truth/src/analysis/mod.rs
Original file line number Diff line number Diff line change
@@ -25,16 +25,6 @@ impl RawTestResults {
}
}

/// Returns the raw metrics received from DogStatsD.
pub fn dsd_metrics(&self) -> &[Metric] {
&self.dsd_metrics
}

/// Returns the raw metrics received from Agent Data Plane.
pub fn adp_metrics(&self) -> &[Metric] {
&self.adp_metrics
}

/// Analyzes the raw metrics from DogStatsD and Agent Data Plane, comparing them to one another.
///
/// # Errors
9 changes: 0 additions & 9 deletions bin/correctness/ground-truth/src/sync.rs
Original file line number Diff line number Diff line change
@@ -57,15 +57,6 @@ pub struct TaskToken {
state: Arc<State>,
}

impl TaskToken {
/// Mark this task as done.
///
/// If no other tasks are still running, this will wake up the waiting task, if any.
pub fn done(self) {
drop(self)
}
}

impl Drop for TaskToken {
fn drop(&mut self) {
// If we're the last worker attached to the coordinator, wake up the waiting task, if any.
24 changes: 0 additions & 24 deletions bin/correctness/millstone/src/config.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ use std::{
path::{Path, PathBuf},
};

use bytesize::ByteSize;
use saluki_error::{generic_error, ErrorContext as _, GenericError};
use serde::Deserialize;

@@ -49,29 +48,6 @@ impl TryFrom<String> for TargetAddress {
}
}

#[derive(Clone, Deserialize)]
#[serde(try_from = "ByteSize")]
pub struct NonZeroByteSize(ByteSize);

impl NonZeroByteSize {
/// Returns the number of bytes represented by this value.
pub fn as_u64(&self) -> u64 {
self.0.as_u64()
}
}

impl TryFrom<ByteSize> for NonZeroByteSize {
type Error = String;

fn try_from(value: ByteSize) -> Result<Self, Self::Error> {
if value.as_u64() == 0 {
Err("value must be non-zero".to_string())
} else {
Ok(Self(value))
}
}
}

#[derive(Clone, Deserialize)]
pub enum Payload {
/// DogStatsD-encoded metrics.
31 changes: 8 additions & 23 deletions bin/correctness/millstone/src/corpus.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ use crate::config::{Config, CorpusBlueprint, Payload, TargetAddress};
/// A generated test corpus.
pub struct Corpus {
payloads: Vec<Bytes>,
max_payload_size: usize,
}

impl Corpus {
@@ -28,23 +27,15 @@ impl Corpus {
let payload_name = blueprint.payload.name();

let rng = StdRng::from_seed(config.seed);
let (payloads, max_payload_size, total_size_bytes) = generate_payloads(rng, blueprint)?;
let (payloads, total_size_bytes) = generate_payloads(rng, blueprint)?;

info!(
"Generated test corpus with {} payloads ({}) in {} format.",
payloads.len(),
total_size_bytes.to_string_as(true),
payload_name
);
Ok(Self {
payloads,
max_payload_size,
})
}

/// Returns the maximum size of any payload in the corpus, in bytes.
pub fn max_payload_size(&self) -> usize {
self.max_payload_size
Ok(Self { payloads })
}

/// Consumes the corpus and returns the raw payloads.
@@ -73,51 +64,45 @@ fn get_finalized_corpus_blueprint(config: &Config) -> Result<CorpusBlueprint, Ge
Ok(blueprint)
}

fn generate_payloads<R>(mut rng: R, blueprint: CorpusBlueprint) -> Result<(Vec<Bytes>, usize, ByteSize), GenericError>
fn generate_payloads<R>(mut rng: R, blueprint: CorpusBlueprint) -> Result<(Vec<Bytes>, ByteSize), GenericError>
where
R: Rng,
{
let mut payloads = Vec::new();

let max_payload_size = match blueprint.payload {
match blueprint.payload {
Payload::DogStatsD(config) => {
// We set our `max_bytes` to 8192, which is the default packet size for the Datadog Agent's DogStatsD
// server. It _can_ be increased beyond that, but rarely is, and so that's the fixed size we're going to
// target here.
let generator = DogStatsD::new(config, &mut rng)?;
generate_payloads_inner(&generator, rng, &mut payloads, blueprint.size, 8192)?
}
};
}

let total_size = payloads.iter().map(|p| p.len() as u64).sum();

if payloads.is_empty() {
Err(generic_error!("No payloads were generated."))
} else {
Ok((payloads, max_payload_size, ByteSize(total_size)))
Ok((payloads, ByteSize(total_size)))
}
}

fn generate_payloads_inner<G, R>(
generator: &G, mut rng: R, payloads: &mut Vec<Bytes>, size: NonZeroUsize, max_bytes: usize,
) -> Result<usize, GenericError>
) -> Result<(), GenericError>
where
G: lading_payload::Serialize,
R: Rng,
{
let mut max_payload_size = 0;

for _ in 0..size.get() {
let mut payload = BytesMut::new();
let mut payload_writer = (&mut payload).writer();
generator.to_bytes(&mut rng, max_bytes, &mut payload_writer)?;

if payload.len() > max_payload_size {
max_payload_size = payload.len();
}

payloads.push(payload.freeze());
}

Ok(max_payload_size)
Ok(())
}
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.80.0"
channel = "1.82.0"