Skip to content

Commit

Permalink
enhancement: make synchronous transforms take a mutable receiver (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobz authored Feb 6, 2025
1 parent fdf121e commit b8af303
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/saluki-components/src/transforms/chained/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Transform for Chained {

// We have to re-associate each subtransform with their allocation group token here, as we don't have access to
// it when the bounds are initially defined.
let subtransforms = self
let mut subtransforms = self
.subtransforms
.into_iter()
.map(|(subtransform_id, subtransform)| {
Expand All @@ -106,7 +106,7 @@ impl Transform for Chained {
_ = health.live() => continue,
maybe_events = context.event_stream().next() => match maybe_events {
Some(mut event_buffer) => {
for (allocation_token, transform) in &subtransforms {
for (allocation_token, transform) in &mut subtransforms {
let _guard = allocation_token.enter();
transform.transform_buffer(&mut event_buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl HostEnrichment {
}

impl SynchronousTransform for HostEnrichment {
fn transform_buffer(&self, event_buffer: &mut FixedSizeEventBuffer) {
fn transform_buffer(&mut self, event_buffer: &mut FixedSizeEventBuffer) {
for event in event_buffer {
if let Some(metric) = event.try_as_metric_mut() {
self.enrich_metric(metric)
Expand Down
2 changes: 1 addition & 1 deletion lib/saluki-core/src/components/transforms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ pub trait Transform {
/// within a single transform component for processing efficiency.
pub trait SynchronousTransform {
/// Transforms the events in the event buffer.
fn transform_buffer(&self, buffer: &mut FixedSizeEventBuffer);
fn transform_buffer(&mut self, buffer: &mut FixedSizeEventBuffer);
}

0 comments on commit b8af303

Please sign in to comment.