refactor(server): extract ResetState into its own module#314
Merged
vieiralucas merged 1 commit intomainfrom Apr 12, 2026
Merged
refactor(server): extract ResetState into its own module#314vieiralucas merged 1 commit intomainfrom
vieiralucas merged 1 commit intomainfrom
Conversation
``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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
crates/fakecloud-server/src/main.rswas 2020 lines. Roughly 300 of those were theResetStatestruct (22 state handles plus three runtime handles), itsreset_service/resetmethods, 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
ResetStateand its impls into a newfakecloud-server::resetmodule, makes the two methodspub(crate), importsResetStateback intomain.rs, and keeps the unrelatedrds_instance_responsetest inmain.rs.main.rs: 2020 → 1712 lines.Scope note: the audit originally suggested splitting
main.rsinto 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 ofmain.rsis wiring that reads top-to-bottom well enough and splitting it further would be churn without much benefit.Test plan
cargo build --workspacecargo fmt --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformance— 1102 passed, 0 failedSummary by cubic
Extracted
ResetStateinto a newfakecloud-server::resetmodule to isolate the admin reset logic and shrinkmain.rs. No behavior change.ResetStateandreset_service/resettocrates/fakecloud-server/src/reset.rs.pub(crate)and importedResetStateback intomain.rs.rds_instance_responsetest inmain.rs; moved the per-service reset test to the new module.main.rsfrom 2020 to 1712 lines.Written for commit 4fcae17. Summary will update on new commits.