refactor: reduce FollowRepository surface area with query objects #12
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
FollowRepositoryhas 19 async methods mixing abstraction levels: single-item CRUD (add_follower,remove_follower), paginated queries (get_followers_page,get_accepted_followers_page), counts (count_followers,count_accepted_followers), status management (update_follower_status,update_following_status), and migration (migrate_follower_actor).Consumers must implement all 19 methods. Tests need 19 stub implementations even when testing one scenario. Adding a method breaks all downstream code.
Similar issues exist in
ActorRepository(7 methods mixing keypairs, remote cache, and announces) andBlocklistRepository(8 methods mixing domain and per-user blocks).Proposal
Option A — Query objects: Replace groups of related methods with a single query method:
Option B — Split into focused sub-traits:
InboundFollowRepository(followers),OutboundFollowRepository(following),FollowMigrationRepository.Option C — Default implementations: Provide default impls for paginated/count methods that delegate to the base methods. Consumers only override for performance.
Files
src/repository/follow.rs(19 methods)src/repository/actor.rs(7 methods)src/repository/blocklist.rs(8 methods)Trade-offs
Dependency
Should be done alongside or before test mock builder (#15) since the trait shape determines mock ergonomics.