-
-
Notifications
You must be signed in to change notification settings - Fork 35
refactor!: use Arc internally in Database
#432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This makes the API more ergonomic, as `Arc` should really just be an implementation detail, rather than something exposed to the user. This is a followup to the discussion here: #419 (comment)
Arc internally in DatabaseArc internally in Database
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the Database type to use Arc internally rather than exposing it in the public API, making the framework more ergonomic for users. The change treats reference counting as an implementation detail rather than a user concern.
- Moved
Arcwrapping insideDatabasestruct and addedCloneimplementation - Removed
RequestDbextractor in favor of directDatabaseextraction viaFromRequestHead - Updated all type signatures throughout the codebase from
Arc<Database>toDatabase
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
cot/src/db.rs |
Core refactoring: wraps DatabaseImpl in Arc internally, adds Clone derive, updates all match expressions to dereference the Arc, removes redundant DatabaseBackend impl for Arc<Database> |
cot/src/request/extractors.rs |
Removes RequestDb wrapper struct and implements FromRequestHead directly on Database type |
cot/src/request.rs |
Updates RequestExt trait method signatures to return &Database instead of &Arc<Database> |
cot/src/project.rs |
Updates all type signatures and trait bounds from Arc<Database> to Database throughout bootstrap and context types |
cot/src/session/store/db.rs |
Updates DbStore to store Database instead of Arc<Database>, removes unused Arc import |
cot/src/auth/db.rs |
Updates DatabaseUserBackend to store Database instead of Arc<Database>, removes unused Arc import |
cot/src/test.rs |
Updates TestDatabase and TestRequestBuilder to use Database instead of Arc<Database> throughout |
cot/src/openapi.rs |
Updates ApiOperationPart implementation from RequestDb to Database |
examples/todo-list/src/main.rs |
Updates handler signatures to use db: Database extractor instead of RequestDb(db): RequestDb, adds Database to imports, removes RequestDb import |
examples/forms/src/main.rs |
Updates handler signatures to use db: Database extractor instead of RequestDb(db): RequestDb, adds Database to imports, removes RequestDb import |
examples/admin/src/main.rs |
Updates handler signatures to use db: Database extractor instead of RequestDb(db): RequestDb, adds Database to imports, removes RequestDb import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
| Branch | arc-database |
| Testbed | github-ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| empty_router/empty_router | 📈 view plot 🚷 view threshold | 6,064.30 µs(+0.10%)Baseline: 6,058.53 µs | 6,795.29 µs (89.24%) |
| json_api/json_api | 📈 view plot 🚷 view threshold | 1,039.80 µs(+1.50%)Baseline: 1,024.45 µs | 1,131.99 µs (91.86%) |
| nested_routers/nested_routers | 📈 view plot 🚷 view threshold | 951.80 µs(+0.49%)Baseline: 947.18 µs | 1,042.46 µs (91.30%) |
| single_root_route/single_root_route | 📈 view plot 🚷 view threshold | 914.14 µs(+0.80%)Baseline: 906.84 µs | 995.54 µs (91.82%) |
| single_root_route_burst/single_root_route_burst | 📈 view plot 🚷 view threshold | 17,438.00 µs(-1.56%)Baseline: 17,715.17 µs | 20,867.06 µs (83.57%) |
Similarly to #432, this drops the `Arc` from `Arc<Cache>` in public APIs to make the interfaces more ergonomic and easier to use for the users.
seqre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This makes the API more ergonomic, as
Arcshould really just be an implementation detail, rather than something exposed to the user.This is a followup to the discussion here:
#419 (comment)