pub struct PostgresStore { /* private fields */ }Expand description
PostgreSQL-backed durability store.
Implementations§
Source§impl PostgresStore
impl PostgresStore
Sourcepub fn connect(conn_str: &str, default_contract: Contract) -> Result<Self>
pub fn connect(conn_str: &str, default_contract: Contract) -> Result<Self>
Connects to PostgreSQL (libpq keyword/URI connection string, e.g.
postgres://user@host/db or host=… user=… dbname=…) and ensures the
schema. The samples survive a full process/system restart in the
database; contracts live in memory and are re-registered on startup.
§Errors
Connection, schema, or (with timescaledb) hypertable-setup failure.
Trait Implementations§
Source§impl DurabilityStore for PostgresStore
impl DurabilityStore for PostgresStore
Source§fn set_contract(&self, topic: &str, contract: Contract) -> Result<()>
fn set_contract(&self, topic: &str, contract: Contract) -> Result<()>
Registers (or replaces) the retention
Contract for topic. The
daemon calls this when it starts serving a topic. Topics without an
explicit contract use the store’s default (Contract::default). Read moreSource§fn store(&self, sample: DurabilitySample) -> Result<()>
fn store(&self, sample: DurabilitySample) -> Result<()>
Persists
sample durably, enforcing the topic contract. Returns
StoreError::OutOfResources when a KEEP_ALL cap
is hit. Read moreSource§fn query(&self, topic: &str, selector: &Selector) -> Result<Page>
fn query(&self, topic: &str, selector: &Selector) -> Result<Page>
Returns one ordered
Page of samples for topic matching selector.
Ordering is (instance_key, sequence). Drive pagination via
Page::next + Selector::after_cursor. Read moreSource§fn unregister(
&self,
topic: &str,
instance_key: &[u8; 16],
now: SystemTime,
) -> Result<()>
fn unregister( &self, topic: &str, instance_key: &[u8; 16], now: SystemTime, ) -> Result<()>
Source§fn cleanup(&self, now: SystemTime) -> Result<usize>
fn cleanup(&self, now: SystemTime) -> Result<usize>
Purges instances whose
unregister time + cleanup-delay is <= now.
Returns the number of purged instances. Read moreSource§fn replay_for_topic(
&self,
topic: &str,
) -> Result<Vec<DurabilitySample>, StoreError>
fn replay_for_topic( &self, topic: &str, ) -> Result<Vec<DurabilitySample>, StoreError>
Auto Trait Implementations§
impl !Freeze for PostgresStore
impl RefUnwindSafe for PostgresStore
impl Send for PostgresStore
impl Sync for PostgresStore
impl Unpin for PostgresStore
impl UnsafeUnpin for PostgresStore
impl UnwindSafe for PostgresStore
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