Skip to content

refactor(ses): split resolve_action by collection and factor action parsers#342

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup-ses-resolve-action
Apr 13, 2026
Merged

refactor(ses): split resolve_action by collection and factor action parsers#342
vieiralucas merged 1 commit intomainfrom
worktree-cleanup-ses-resolve-action

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

  • `resolve_action` used to be a single ~450-line `match (method, segs.len())` with a guard on `segs[2]` on almost every arm. It now dispatches on the top-level collection first and delegates to a per-collection helper that owns its own `(method, len)` match — same pattern as PR refactor(apigatewayv2): split resolve_action by endpoint shape #335 for ApiGatewayV2. Collections: `account`, `identities`, `configuration-sets`, `templates`, `contact-lists`, `suppression`, `custom-verification-email-templates`, `dedicated-ip-pools`, `dedicated-ips`, `multi-region-endpoints`, `import-jobs`, `export-jobs`, `tenants`, `resources`, `reputation`. Simple one-off leaf endpoints stay inline.
  • Introduce a `decode_segment` helper and a `ResolvedAction` type alias so the helper signatures read cleanly.
  • Split `parse_action` (v1.rs) into one parser per `ReceiptAction` variant (`parse_s3_action`, `parse_sns_action`, `parse_lambda_action`, `parse_bounce_action`, `parse_add_header_action`, `parse_stop_action`) chained via `Option::or_else`. Mirrors the shape of `receipt_action_xml` from PR refactor(ses): extract receipt_action_xml from rule_to_xml #327.
  • Extract `send_bulk_destination` from `send_bulk_templated_email` so the per-destination record + `SentEmail` construction is a named function.

Test plan

  • `cargo fmt`
  • `cargo clippy --workspace --all-targets -- -D warnings`
  • `cargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformance`

Summary by cubic

Split SES v2 routing and v1 receipt action parsing into small, focused helpers to improve readability and make future changes easier. No behavior changes.

  • Refactors
    • Reworked resolve_action to dispatch by top-level collection and delegate to per-collection helpers; simple leaf endpoints (e.g. outbound-emails, outbound-bulk-emails, tags, metrics/batch) stay inline.
    • Added decode_segment and a ResolvedAction type alias for clearer signatures.
    • Split v1::parse_action into per-variant parsers (parse_s3_action, parse_sns_action, parse_lambda_action, parse_bounce_action, parse_add_header_action, parse_stop_action) chained via or_else.
    • Extracted send_bulk_destination from send_bulk_templated_email to isolate per-destination record creation and SentEmail construction.

Written for commit 2bbe09a. Summary will update on new commits.

…parsers

- resolve_action now dispatches on the top-level collection (segs[2]) to
  per-collection helpers, each of which owns its own (method, len) match.
  Groups: account, identities, configuration-sets, templates,
  contact-lists, suppression, custom-verification-email-templates,
  dedicated-ip-pools, dedicated-ips, multi-region-endpoints, import-jobs,
  export-jobs, tenants, resources, reputation. Simple leaf endpoints
  (outbound-emails, outbound-bulk-emails, tags, metrics/batch, etc.) stay
  inline at the top level.
- Extract decode_segment helper and ResolvedAction type alias.
- Split parse_action into one parser per ReceiptAction variant (S3, SNS,
  Lambda, Bounce, AddHeader, Stop), chained via Option::or_else.
- Extract send_bulk_destination from send_bulk_templated_email so the
  per-destination body construction is a named function.
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 2 files

@vieiralucas vieiralucas merged commit 0d1aea3 into main Apr 13, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup-ses-resolve-action branch April 13, 2026 12:07
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