Skip to content

refactor(rds): extract engine defaults and final-snapshot helpers#329

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

refactor(rds): extract engine defaults and final-snapshot helpers#329
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+rds-splits

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

`create_db_instance` and `delete_db_instance` each had multi-line bodies that didn't need to live inline.

  • `create_db_instance`: the port, parameter group, and logical database name defaults were all inline match-on-engine blocks. Move them into `default_port_for_engine`, `default_parameter_group` (which handles the `default.postgres16` / `default.mysql8.0` / `default.mariadb10.11` naming), and reuse the existing `default_db_name` helper. The operation body loses ~35 lines and reads top-to-bottom without stalling on default values.
  • `delete_db_instance`: the 80-line 'create final snapshot' block (runtime check, lock-drop read of the source instance, `dump_database` call, write-locked snapshot insert) becomes its own `create_final_db_snapshot` method. The conflict check runs twice on purpose — once under the read lock to avoid paying for the dump, once under the write lock to make the commit atomic — and the helper preserves that.

No behavior change.

Test plan

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

Summary by cubic

Refactored RDS to extract engine defaults and final snapshot logic into helpers, making create_db_instance and delete_db_instance shorter and easier to read. No behavior change.

  • Refactors
    • Moved default port and parameter group selection to default_port_for_engine and default_parameter_group; reused default_db_name.
    • Pulled final snapshot flow into create_final_db_snapshot, preserving the double conflict check and lock semantics.

Written for commit 76aaa05. Summary will update on new commits.

create_db_instance and delete_db_instance each had multi-line bodies
that didn't need to live inline.

- create_db_instance: the port, parameter group, and logical database
  name defaults were all inline match-on-engine blocks. Move them into
  default_port_for_engine, default_parameter_group (which handles the
  'default.postgres16' / 'default.mysql8.0' / 'default.mariadb10.11'
  naming), and reuse the existing default_db_name helper. The
  operation body loses ~35 lines and reads top-to-bottom without
  stalling on default values.

- delete_db_instance: the 80-line 'create final snapshot' block
  (runtime check, lock-drop read of the source instance, dump_database
  call, write-locked snapshot insert) becomes its own
  create_final_db_snapshot method. The conflict check runs twice on
  purpose — once under the read lock to avoid paying for the dump, once
  under the write lock to make the commit atomic — and the helper
  preserves that.

No behavior change.
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 1 file

@vieiralucas vieiralucas merged commit 85a6354 into main Apr 13, 2026
44 of 46 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup+rds-splits branch April 13, 2026 02:03
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