Skip to main content

DatabaseEndpointResolver

Trait DatabaseEndpointResolver 

Source
pub trait DatabaseEndpointResolver: Send + Sync {
    // Required method
    fn resolve_url(&self, logical_name: &str) -> Result<Option<String>, Error>;
}
Expand description

Resolve a physical connection URL for a logical database name at bootstrap.

Wire with crate::ValenceBuilder::endpoint_resolver.

§Examples

use valence_core::{DatabaseEndpointResolver, StaticEndpointResolver};

let resolver = StaticEndpointResolver::from_pairs(&[
    ("billing", "postgres://db.example/billing".to_string()),
]);
assert_eq!(
    resolver.resolve_url("billing").unwrap().as_deref(),
    Some("postgres://db.example/billing")
);

Required Methods§

Source

fn resolve_url(&self, logical_name: &str) -> Result<Option<String>, Error>

Return Ok(None) when the logical name has no mapped URL.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§