Skip to content

Commit

Permalink
ref: Remove redundant InsertMetric
Browse files Browse the repository at this point in the history
  • Loading branch information
jjbayer committed Mar 25, 2021
1 parent 66f6370 commit 47d6fdc
Showing 1 changed file with 6 additions and 28 deletions.
34 changes: 6 additions & 28 deletions relay-metrics/src/aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,32 +487,6 @@ impl Actor for Aggregator {
}
}

/// A message containing a [`Metric`] to be inserted into the aggregator.
#[derive(Debug)]
pub struct InsertMetric {
metric: Metric,
}

impl InsertMetric {
/// Creates a new message containing a [`Metric`].
pub fn new(metric: Metric) -> Self {
Self { metric }
}
}

impl Message for InsertMetric {
type Result = Result<(), AggregateMetricsError>;
}

impl Handler<InsertMetric> for Aggregator {
type Result = Result<(), AggregateMetricsError>;

fn handle(&mut self, message: InsertMetric, _context: &mut Self::Context) -> Self::Result {
let InsertMetric { metric } = message;
self.insert(metric)
}
}

/// A message containing a list of [`Metric`]s to be inserted into the aggregator.
#[derive(Debug)]
pub struct InsertMetrics {
Expand Down Expand Up @@ -761,7 +735,9 @@ mod tests {
let mut metric = some_metric();
metric.timestamp = UnixTimestamp::now();
aggregator
.send(InsertMetric { metric })
.send(InsertMetrics {
metrics: vec![metric],
})
.and_then(move |_| aggregator.send(BucketCountInquiry))
.map_err(|_| ())
.and_then(|bucket_count| {
Expand Down Expand Up @@ -805,7 +781,9 @@ mod tests {
let mut metric = some_metric();
metric.timestamp = UnixTimestamp::now();
aggregator
.send(InsertMetric { metric })
.send(InsertMetrics {
metrics: vec![metric],
})
.map_err(|_| ())
.and_then(|_| {
// Immediately after sending the metric, nothing has been flushed:
Expand Down

0 comments on commit 47d6fdc

Please sign in to comment.