Skip to content

refactor(server): extract Cli and introspection helpers from main.rs#319

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+server-startup-split
Apr 13, 2026
Merged

refactor(server): extract Cli and introspection helpers from main.rs#319
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+server-startup-split

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

  • Extract the Cli struct (clap parser) from crates/fakecloud-server/src/main.rs into a new crates/fakecloud-server/src/cli.rs.
  • Add a small Cli::endpoint_url() method that derives the public URL from the configured bind address (rewriting wildcard hosts 0.0.0.0 / [::] to localhost so the URL is meaningful when handed back to clients). main.rs no longer needs to do this string surgery inline.
  • Extract the four introspection response builders (rds_instance_response, elasticache_cluster_response, elasticache_replication_group_response, elasticache_serverless_cache_response) into a new crates/fakecloud-server/src/introspection.rs. These translate raw service state into the public SDK types and exist explicitly so the GET /_fakecloud/... endpoints don't leak runtime-internal fields like RDS master passwords.
  • The existing rds_instance_response_omits_password_but_keeps_runtime_metadata test moves with the helper.
  • main.rs shrinks by 165 lines and now contains only the bind / orchestration / shutdown logic.

Test plan

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

Summary by cubic

Split server startup by moving the CLI parser and introspection builders out of main.rs, keeping startup orchestration focused. Added Cli::endpoint_url() to derive a client-facing URL (rewrites 0.0.0.0/[::] to localhost).

  • Refactors
    • New crates/fakecloud-server/src/cli.rs: defines Cli (via clap) and endpoint_url().
    • New crates/fakecloud-server/src/introspection.rs: response builders for RDS/ElastiCache map runtime state to fakecloud-sdk types without secrets; includes the password-redaction test.
    • main.rs now imports these helpers and focuses on bind/setup; reduced by ~165 lines.

Written for commit b32db67. Summary will update on new commits.

- New crates/fakecloud-server/src/cli.rs holds the Cli struct and a
  small endpoint_url() helper that derives the public URL from the
  configured bind address (rewriting wildcard hosts to localhost).
- New crates/fakecloud-server/src/introspection.rs hosts the four
  introspection response builders that translate raw service state
  into the public RdsInstance / ElastiCache* SDK types, plus the
  existing test that pins the password-redaction contract.
- main.rs now wires these in via mod cli; mod introspection; and
  shrinks by 165 lines, leaving only the bind/setup orchestration.
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 3 files

@vieiralucas vieiralucas merged commit dccee07 into main Apr 13, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup+server-startup-split branch April 13, 2026 00:49
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