Skip to content

refactor(rust): Apply the latest Rust coding guidelines: - #382

Merged
LinZhihao-723 merged 1 commit into
y-scope:mainfrom
LinZhihao-723:style-refactor
Jul 8, 2026
Merged

refactor(rust): Apply the latest Rust coding guidelines:#382
LinZhihao-723 merged 1 commit into
y-scope:mainfrom
LinZhihao-723:style-refactor

Conversation

@LinZhihao-723

@LinZhihao-723 LinZhihao-723 commented Jul 8, 2026

Copy link
Copy Markdown
Member
  • Update yscope-dev-utils to the latest commit to enforce per-item import formatting.
  • Convert multi-file modules to the mod.rs layout.
  • Clean up the deep tonic-generated import paths behind tidy re-exports in spider-proto-rust.

Description

As the title suggests.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • Ensure all workflows pass.

Summary by CodeRabbit

  • New Features

    • Expanded public access to several service interfaces and helper types across the storage, scheduler, execution manager, and task execution libraries.
  • Refactor

    • Cleaned up module imports and re-exports throughout the codebase for clearer, more consistent organization.
    • Reworked some module structure in shared components without changing runtime behaviour.
  • Chores

    • Updated an internal subproject reference to a newer revision.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR reformats Rust use import declarations across nearly the entire workspace, converting grouped/nested imports into individual per-item statements and splitting some grouped pub use re-exports. Separately, spider-storage's db.rs and state.rs files are restructured into db/mod.rs and state/mod.rs directory modules preserving the same public re-exports.

Changes

Storage module directory split

Layer / File(s) Summary
db.rs split into db/mod.rs
components/spider-storage/src/db/mod.rs, .../db/error.rs, .../db/mariadb.rs, .../db/protocol.rs
db.rs is removed; db/mod.rs declares error, mariadb, and protocol submodules and re-exports DbError, MariaDbStorageConnector, and protocol management traits; submodule imports are reformatted.
state.rs split into state/mod.rs
components/spider-storage/src/state/mod.rs, .../state/error.rs, .../state/job_cache.rs, .../state/job_cache_gc.rs, .../state/runtime.rs, .../state/service.rs, .../state/test_utils.rs
state.rs is removed; state/mod.rs declares error, job_cache, job_cache_gc, runtime, service submodules (and test_utils under cfg(test)) and re-exports the same public types/constructors; submodule imports are reformatted.

Workspace-wide import formatting cleanup

Layer / File(s) Summary
Core and derive crates
components/spider-core/src/..., components/spider-derive/src/...
std, serde, sqlx, semver, strum, and crate-local imports are split into individual use statements; no logic changes.
Client and proto-rust crate
components/spider-client/src/..., components/spider-proto-rust/src/...
Grouped imports are split; lib.rs adds explicit pub use re-exports for scheduler and storage gRPC service client/server types alongside the existing generated code includes.
Execution manager crate
components/spider-execution-manager/src/...
std, tokio, tonic, spider_core, and spider_proto_rust imports are split into individual statements; client/mod.rs re-exports are reformatted.
Scheduler crate
components/spider-scheduler/src/...
Grouped imports are split into individual statements; lib.rs re-exports are reformatted from one aggregated statement into per-item pub use lines.
Storage crate (remaining files and tests)
components/spider-storage/src/..., components/spider-storage/tests/...
Remaining spider-storage source and test files have grouped imports split into individual statements; lib.rs re-exports DatabaseConfig/ServerConfig separately.
Task executor, TDL, and utils crates
components/spider-task-executor/src/..., components/spider-tdl/src/..., components/spider-tdl-derive/src/..., components/spider-tdl/tests/..., components/spider-utils/src/...
Grouped use and pub use statements are split into individual per-item lines.
Examples, integration tests, and dev-utils pointer
examples/huntsman/..., tests/huntsman/..., tools/yscope-dev-utils
Test/example imports are split into individual statements; the yscope-dev-utils submodule pointer is updated to a new commit.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • y-scope/spider#325: Touches the same task-executor binary file introduced by that PR, now with reformatted imports.
  • y-scope/spider#326: Reformats imports in process_pool.rs, the same module introduced by that PR.

Suggested reviewers: sitaowang1998

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s import, module layout, and re-export refactor work while staying concise and Conventional Commits-like.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@LinZhihao-723
LinZhihao-723 marked this pull request as ready for review July 8, 2026 19:42
@LinZhihao-723
LinZhihao-723 requested review from a team and sitaowang1998 as code owners July 8, 2026 19:42
@LinZhihao-723
LinZhihao-723 merged commit f533af8 into y-scope:main Jul 8, 2026
24 checks passed
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.

2 participants