essential-contributions / essential-node

Derive current head from essential builder and sync state between nodes
Apache License 2.0
2 stars 1 forks source link

Move `essential_node::db` module to `essential_node_db::pool` #74

Closed mitchmindtree closed 1 month ago

mitchmindtree commented 2 months ago

From slack discussion:


Maybe we should move node::db::ConnectionPool into a node_db::pool or node_db::tokio module or similar behind a feature?

It currently feels a bit odd to need to import essential_node just to get access to the connection pool over the DB, which is very specific to the DB.

If you're using essential_node_db, you almost always want the connection pool, but you might not want the relayer streams or whatever else (i.e. like the builder).

So I guess I'm thinking the refactor would look like this:

  1. Move node::db module to node_db::pool and move the rusqlite-pool dependency to node_db.
  2. Feature gate the node_db::pool module and rusqlite-pool dep in case a user just wants the raw sync fns (and doesn't use tokio or whatever).
  3. Re-export node_db::pool::ConnectionPool from node_db (behind feature gate) so that you can use it like node_db::ConnectionPool.

Bonus:

  1. Change essential-node-api to just depend on essential-node-db (won't need the whole essential-node crate anymore).
  2. Possibly re-export essential_node_db as db in essential-node to emulate the existing behaviour (e.g. this would allow essential_node::db::ConnectionPool to still be available).