Skip to content

buzz-db: break up lib.rs — move impl Db methods to domain modules #2

Description

@TheSentinel454

Problem

lib.rs is 9,491 lines with a single impl Db block containing 240 public methods. The majority are thin delegation wrappers that forward &self.pool to a free function in a domain module and add a #[datastore_span] attribute. This delegation layer alone accounts for ~5,000 lines of boilerplate.

Proposed change

Move each group of impl Db methods into their respective domain module files. Rust allows multiple impl Db blocks across files within the same crate, so channel.rs would own Db::create_channel, Db::add_member, etc. directly — eliminating the free-function-plus-wrapper indirection.

After this change, lib.rs would contain only:

  • The Db struct definition and fields
  • Pool configuration (DbConfig, connection setup)
  • ReadSession and replica routing infrastructure
  • mod declarations and re-exports
  • Cross-cutting helpers (insert_mentions, event_replacement_lock_key)

Target: ~800–1,000 lines in lib.rs.

Priority

High — biggest single-file maintainability problem, mechanical to execute, reduces merge conflicts.

Dependencies

None — can be done independently. Items like extracting community.rs (#TBD) and moving misplaced types (#TBD) are naturally done alongside this.

🤖 AI review update (2026-08-23)

The goal is clear, but this should be an incremental tracker rather than a single 9,000-line relocation. Split work by domain (replacement, community, channel membership, API token/allowlist, reminders), and require each slice to move its tests and datastore spans while preserving public API behavior. This lowers merge-conflict and review risk in an active codebase.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions