[nexus] Access DB via "connection", not "pool" #4132
Labels
database
Related to database access
development
Bugs, paper cuts, feature requests, or other thoughts on making omicron development better
This is a gnarly implementation detail that arose out of a poor decision I made back in async-bb8-diesel.
In async-bb8-diesel, we define a trait named
AsyncConnection
, which allows callers to execute a variety of asynchronous Diesel operations. This trait is implemented for both the connection pool itself, as well as individual connections.This was intended for developer convenience -- if you wanted to use a "pool" object directly to issue operations, you could. If you wanted to use a "connection" object to issue operations, you could check it out of the pool and use that too.
This approach has a couple of downsides:
This can culminate in code like the following:
omicron/nexus/db-queries/src/db/datastore/service.rs
Lines 47 to 55 in 46ffb37
If we universally just "checked out connections before using them", that code could be written as:
(and hey, look, that has no generics, will be faster to compile, and will be easier to reason about!)
The text was updated successfully, but these errors were encountered: