Skip to content

refactor(eventbridge): split start_replay into phases#349

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup-eventbridge-start-replay
Apr 13, 2026
Merged

refactor(eventbridge): split start_replay into phases#349
vieiralucas merged 1 commit intomainfrom
worktree-cleanup-eventbridge-start-replay

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

`start_replay` was ~275 lines combining input parsing, destination/archive validation, event collection, replay record insertion, and per-target delivery fan-out. Extract three helpers so the outer function reads as a 70-line sequence of named phases:

  • `StartReplayInput::from_body` owns the parse + validate phase (ReplayName, EventSourceArn, EventStartTime/EndTime, Destination, destination ARN shape check).
  • `collect_replay_events_with_targets` walks the archive, filters events into the replay window, and fans each out against the bus's rules to collect matching targets.
  • `deliver_replay_event_to_target` becomes a method on `EventBridgeService` so the per-protocol dispatch (sqs / sns / lambda / logs / states / http) is reachable as its own named helper — same shape as the SNS fan-out split in PR refactor(sns): split publish topic fan-out into subscribers + per-protocol deliverers #344.

Test plan

  • `cargo fmt`
  • `cargo clippy --workspace --all-targets -- -D warnings`
  • `cargo test -p fakecloud-eventbridge --lib` — 60 passed
  • `cargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformance`

Summary by cubic

Refactored EventBridge start_replay into clear phases to improve readability and reuse without changing behavior. The outer function is now ~70 lines and preserves AWS validation order.

  • Refactors
    • Added StartReplayInput::from_body for parsing and validating inputs (including destination ARN).
    • Added collect_replay_events_with_targets to filter archive events by time and match rules on the destination bus.
    • Added deliver_replay_event_to_target to encapsulate per-protocol delivery (SQS, SNS, Lambda, Logs, Step Functions, HTTP).

Written for commit 10616f6. Summary will update on new commits.

start_replay was ~275 lines combining input parsing, destination/archive
validation, event collection, replay record insertion, and per-target
delivery fan-out. Extract:

- StartReplayInput::from_body for the parse + validate phase
- collect_replay_events_with_targets to walk the archive + match rules
- deliver_replay_event_to_target as a method on the service so the
  per-protocol dispatch (sqs/sns/lambda/logs/states/http) is reachable
  as its own named helper

The outer function now reads as a 70-line sequence of named phases.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@vieiralucas vieiralucas merged commit d9ee4a1 into main Apr 13, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup-eventbridge-start-replay branch April 13, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant