pub enum Store {
Memory(Mutex<HashMap<String, Address>>),
Sqlite(Mutex<Connection>),
Postgres(Pool),
}Variants§
Implementations§
Source§impl Store
impl Store
pub fn memory() -> Self
pub fn sqlite(path: &Path) -> Result<Self, String>
Sourcepub async fn postgres(url: &str) -> Result<Self, String>
pub async fn postgres(url: &str) -> Result<Self, String>
Connect, and create the schema if it is missing. Fails rather than starting a server whose every request would 503.
TLS follows the URL’s sslmode, as libpq does: prefer (the default)
uses TLS when the server offers it, require refuses plaintext, and
disable never tries. TLS always verifies the certificate and host
name against Mozilla’s roots, so a managed database (Neon, Supabase,
RDS, …) works with its URL as given.
Sourcepub fn pg_pool(&self) -> Option<&Pool>
pub fn pg_pool(&self) -> Option<&Pool>
The connection pool, when this store is Postgres; fleet health sync shares it.
pub async fn put(&self, a: &Address) -> Result<(), StoreUnavailable>
Sourcepub async fn get(
&self,
value: &str,
) -> Result<Option<Address>, StoreUnavailable>
pub async fn get( &self, value: &str, ) -> Result<Option<Address>, StoreUnavailable>
The address, unless unknown or expired (expired rows are evicted on read).
Sourcepub async fn sweep(&self) -> Result<usize, StoreUnavailable>
pub async fn sweep(&self) -> Result<usize, StoreUnavailable>
Reap expired rows. get only evicts rows somebody asks for, and nobody
asks for an address after it expired; without this they pile up.
Auto Trait Implementations§
impl !Freeze for Store
impl !RefUnwindSafe for Store
impl !UnwindSafe for Store
impl Forget for Store
impl Move for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more