Skip to content

Commit bed786b

Browse files
committed
Pass drop as an Outcome and allow the outerscope to manage how that outcome is handled
1 parent b49f9d5 commit bed786b

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

relay-server/src/services/processor/replay.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub fn process(
7272
client_addr,
7373
user_agent,
7474
) {
75-
ProcessingAction::Drop(action) => action,
75+
ProcessingAction::Drop(outcome) => ItemAction::Drop(outcome),
7676
ProcessingAction::Keep => ItemAction::Keep,
7777
ProcessingAction::Replace(replay_event) => {
7878
item.set_payload(ContentType::Json, replay_event);
@@ -87,7 +87,7 @@ pub fn process(
8787
scrubbing_enabled,
8888
&mut scrubber,
8989
) {
90-
ProcessingAction::Drop(action) => action,
90+
ProcessingAction::Drop(outcome) => ItemAction::Drop(outcome),
9191
ProcessingAction::Keep => ItemAction::Keep,
9292
ProcessingAction::Replace(replay_recording) => {
9393
item.set_payload(ContentType::OctetStream, replay_recording);
@@ -104,7 +104,7 @@ pub fn process(
104104
scrubbing_enabled,
105105
&mut scrubber,
106106
) {
107-
ProcessingAction::Drop(action) => action,
107+
ProcessingAction::Drop(outcome) => ItemAction::Drop(outcome),
108108
ProcessingAction::Keep => ItemAction::Keep,
109109
ProcessingAction::Replace((replay_event, replay_recording, replay_video)) => {
110110
item.set_replay_video_events(replay_event, replay_recording);
@@ -120,7 +120,7 @@ pub fn process(
120120
}
121121

122122
enum ProcessingAction<T> {
123-
Drop(ItemAction),
123+
Drop(Outcome),
124124
Keep,
125125
Replace(T),
126126
}
@@ -143,12 +143,12 @@ fn handle_replay_event_item(
143143
},
144144
Err(error) => {
145145
relay_log::warn!(error = &error as &dyn Error, "invalid replay event");
146-
ProcessingAction::Drop(ItemAction::Drop(Outcome::Invalid(match error {
146+
ProcessingAction::Drop(Outcome::Invalid(match error {
147147
ReplayError::NoContent => DiscardReason::InvalidReplayEventNoPayload,
148148
ReplayError::CouldNotScrub(_) => DiscardReason::InvalidReplayEventPii,
149149
ReplayError::CouldNotParse(_) => DiscardReason::InvalidReplayEvent,
150150
ReplayError::InvalidPayload(_) => DiscardReason::InvalidReplayEvent,
151-
})))
151+
}))
152152
}
153153
}
154154
}
@@ -215,9 +215,7 @@ fn handle_replay_recording_item(
215215
Ok(recording) => ProcessingAction::Replace(recording),
216216
Err(e) => {
217217
relay_log::warn!("replay-recording-event: {e} {event_id:?}");
218-
ProcessingAction::Drop(ItemAction::Drop(Outcome::Invalid(
219-
DiscardReason::InvalidReplayRecordingEvent,
220-
)))
218+
ProcessingAction::Drop(Outcome::Invalid(DiscardReason::InvalidReplayRecordingEvent))
221219
}
222220
}
223221
}
@@ -247,9 +245,9 @@ fn handle_replay_video_item(
247245
Ok(result) => result,
248246
Err(e) => {
249247
relay_log::warn!("replay-video-event: {e} {event_id:?}");
250-
return ProcessingAction::Drop(ItemAction::Drop(Outcome::Invalid(
248+
return ProcessingAction::Drop(Outcome::Invalid(
251249
DiscardReason::InvalidReplayVideoEvent,
252-
)));
250+
));
253251
}
254252
};
255253

@@ -279,9 +277,7 @@ fn handle_replay_video_item(
279277

280278
// Verify the replay-video payload is not empty.
281279
if event.replay_video.is_empty() {
282-
return ProcessingAction::Drop(ItemAction::Drop(Outcome::Invalid(
283-
DiscardReason::InvalidReplayVideoEvent,
284-
)));
280+
return ProcessingAction::Drop(Outcome::Invalid(DiscardReason::InvalidReplayVideoEvent));
285281
}
286282

287283
ProcessingAction::Replace((replay_event, replay_recording, event.replay_video))

0 commit comments

Comments
 (0)