pub trait DbResolver:
Send
+ Sync
+ 'static {
// Required method
fn resolve(&self, name: &str) -> Option<Arc<Db>>;
// Provided method
fn token(&self) -> Option<String> { ... }
}Expand description
How a caller resolves a database name to an open Db.
A trait object rather than a concrete handle so this module does not depend
on server::Manager — which keeps the protocol code unit-testable against a
plain Db with no HTTP stack in the way.
Required Methods§
Sourcefn resolve(&self, name: &str) -> Option<Arc<Db>>
fn resolve(&self, name: &str) -> Option<Arc<Db>>
Look up an open database by the name the client connected with.
MAY BLOCK. The implementation is allowed to take a lock, so this is
always called from spawn_blocking — never on an async worker. Taking
a tokio RwLock::blocking_read() on a runtime thread panics outright
(“Cannot block the current thread from within a runtime”), which is
exactly how the first cut of this failed.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl DbResolver for Manager
Start the nedbd v2 server. Lets the Postgres read endpoint share this process’s already-open databases instead of opening its own handles — which the exclusive data-dir LOCK would refuse anyway, and rightly so.