Skip to content

1525-04b: Migrate consumers to narrow persistence traits #1715

@josecelano

Description

@josecelano

Goal

Replace every use of Arc<Box<dyn Database>> in production and test code with the specific narrow trait the consumer actually needs (AuthKeyStore, TorrentMetricsStore, WhitelistStore, or SchemaMigrator). After this subissue the Database aggregate supertrait becomes a purely internal compile-time guard that is no longer part of the public surface of tracker-core.

Background

Subissue #1525-04 (#1713) introduced the four narrow traits and kept Database as an aggregate supertrait so that consumer call sites did not need to change.

Now that the structural split is in place, this subissue wires consumers to the narrow traits they actually need.

Spec

Full spec: docs/issues/1525-04b-migrate-consumers-to-narrow-traits.md

Tasks

  1. Introduce DatabaseStores struct
  2. Update initialize_database return type to DatabaseStores
  3. Update TrackerCoreContainer to use DatabaseStores
  4. Update individual consumers to accept narrow traits
  5. Update tests in authentication/handler.rs (use MockAuthKeyStore directly)
  6. Update axum-rest-tracker-api-server test helper force_database_error
  7. Update benchmark binary operations to accept narrow traits
  8. Make Database private (stop re-exporting from databases/mod.rs)

Acceptance Criteria

  • Arc<Box<dyn Database>> appears only inside databases/ (driver + traits)
  • Each consumer holds only the narrow trait(s) it uses
  • Database is no longer re-exported from databases/mod.rs
  • Tests in authentication/handler.rs use MockAuthKeyStore directly
  • force_database_error helper in axum-rest-tracker-api-server is updated
  • Benchmark operations accept narrow traits
  • cargo test --workspace --all-targets passes
  • linter all exits with code 0

References

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions