Skip to content

refactor(server): extract ResetState into its own module#314

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+server-main-split
Apr 12, 2026
Merged

refactor(server): extract ResetState into its own module#314
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+server-main-split

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 12, 2026

Summary

crates/fakecloud-server/src/main.rs was 2020 lines. Roughly 300 of those were the ResetState struct (22 state handles plus three runtime handles), its reset_service / reset methods, and the test that exercises them.

That's a cohesive unit with one responsibility — letting the admin reset endpoint clear per-service state — and it has no reason to sit in the entry-point file.

This PR moves ResetState and its impls into a new fakecloud-server::reset module, makes the two methods pub(crate), imports ResetState back into main.rs, and keeps the unrelated rds_instance_response test in main.rs.

main.rs: 2020 → 1712 lines.

Scope note: the audit originally suggested splitting main.rs into several modules (args, state init, delivery, registry, reset). This PR does the cleanest boundary — the reset logic, which is a self-contained slice. The rest of main.rs is wiring that reads top-to-bottom well enough and splitting it further would be churn without much benefit.

Test plan

  • cargo build --workspace
  • cargo fmt --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformance — 1102 passed, 0 failed
  • CI green

Summary by cubic

Extracted ResetState into a new fakecloud-server::reset module to isolate the admin reset logic and shrink main.rs. No behavior change.

  • Refactors
    • Moved ResetState and reset_service/reset to crates/fakecloud-server/src/reset.rs.
    • Marked the methods pub(crate) and imported ResetState back into main.rs.
    • Kept the unrelated rds_instance_response test in main.rs; moved the per-service reset test to the new module.
    • Reduced main.rs from 2020 to 1712 lines.

Written for commit 4fcae17. Summary will update on new commits.

``main.rs`` was 2020 lines. Roughly 300 of those were the ``ResetState``
struct (22 state handles plus three runtime handles), its
``reset_service``/``reset`` methods and the test that exercises them.
That's a cohesive unit with a single responsibility (letting the admin
reset endpoint clear per-service state) and it has no reason to sit in
the entry-point file.

This commit moves ``ResetState`` and its impls to a new
``fakecloud-server::reset`` module, makes the two methods ``pub(crate)``,
imports ``ResetState`` back into ``main.rs``, and keeps the
``rds_instance_response`` test in ``main.rs`` (since it doesn't belong
to reset).

``main.rs`` goes from 2020 to 1712 lines. No behavior change; 1102
unit tests still pass.
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 e850eab into main Apr 12, 2026
22 of 23 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup+server-main-split branch April 12, 2026 23:38
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