Skip to content

refactor(logs): extract subscription filter delivery and promote action list#336

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+logs-splits
Apr 13, 2026
Merged

refactor(logs): extract subscription filter delivery and promote action list#336
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+logs-splits

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

Two touches in fakecloud-logs:

  • `put_log_events` had an 80-line inline block that applied each subscription filter's pattern to the accepted log events, wrapped the matches in the `DATA_MESSAGE` envelope, gzip-compressed and base64-encoded the payload, and then fanned out to one of three destination kinds (SQS / Lambda / Kinesis) with a different wire shape each. Move that into `deliver_to_subscription_filter` so the top-level loop is just the usual 'for each matching filter, deliver' pattern.
  • `supported_actions` returned a 117-entry inline array literal constructed on every call (minor, but the pattern is that service trait implementations should return a borrow of a static slice). Lift the array into a file-level `SUPPORTED_ACTIONS` const and return that.

Test plan

  • `cargo fmt`
  • `cargo clippy --workspace --all-targets -- -D warnings`
  • `cargo test -p fakecloud-logs` (129 passed)

Summary by cubic

Refactors the CloudWatch Logs service in fakecloud-logs by extracting subscription filter delivery from put_log_events and promoting the supported action list to a static constant. This simplifies the main loop and avoids per-call allocations without changing behavior.

  • Refactors
    • Added deliver_to_subscription_filter(...) to handle pattern matching, DATA_MESSAGE wrapping, gzip+base64, and fan-out to SQS/Lambda/Kinesis; replaces the inline block in put_log_events.
    • Moved the 117-item action list to SUPPORTED_ACTIONS and updated supported_actions() to return a static borrow.

Written for commit 0e80e02. Summary will update on new commits.

…on list

Two touches in fakecloud-logs:

- put_log_events had an 80-line inline block that applied each
  subscription filter's pattern to the accepted log events, wrapped
  the matches in the DATA_MESSAGE envelope, gzip-compressed and
  base64-encoded the payload, and then fanned out to one of three
  destination kinds (SQS / Lambda / Kinesis) with a different wire
  shape each. Move that into deliver_to_subscription_filter so the
  top-level loop is just the usual 'for each matching filter, deliver'
  pattern.

- supported_actions returned a 117-entry inline array literal
  constructed on every call (minor, but the pattern is that service
  trait implementations should return a borrow of a static slice).
  Lift the array into a file-level SUPPORTED_ACTIONS const and return
  that.
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 d501715 into main Apr 13, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup+logs-splits branch April 13, 2026 02:28
vieiralucas added a commit that referenced this pull request Apr 13, 2026
…cyInput

- Promote IamService::supported_actions inline 130-element &[&str] to a
  file-level SUPPORTED_ACTIONS const; same shape PR #336 used for logs.
- Extract CreatePolicyInput::from_query from create_policy. The parse +
  validate prologue (PolicyName, PolicyDocument, Path, Description, Tags
  + tag validation, MalformedPolicyDocument check) is now isolated from
  the state-mutation flow.

list_policies (49L) audited in the same pass and judged clean: most of
the body is parameter validation calls, with a short filter+render
tail. Splitting would just rearrange validate_* calls.
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