Skip to main content

ChangeStream

Trait ChangeStream 

Source
pub trait ChangeStream:
    Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn write(&self, id: &ObjectId, size: u64, expires_at: Option<SystemTime>);
    fn update(&self, id: &ObjectId, expires_at: Option<SystemTime>);
    fn delete(&self, id: &ObjectId);
    fn join<'life0, 'async_trait>(
        &'life0 self,
        timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Publishes the changes a single backend makes to the objects it stores.

See module docs.

Required Methods§

Source

fn write(&self, id: &ObjectId, size: u64, expires_at: Option<SystemTime>)

Reports that id now occupies size bytes. Used for new writes and overwrites.

Source

fn update(&self, id: &ObjectId, expires_at: Option<SystemTime>)

Reports that id’s expiration moved, with its stored size unchanged.

Source

fn delete(&self, id: &ObjectId)

Reports that id was deleted explicitly. Does not account for automatic GC.

Source

fn join<'life0, 'async_trait>( &'life0 self, timeout: Duration, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Blocks until reported records have been delivered, or timeout elapses.

Call this during shutdown to drain the change stream queue. Waits for reported records to be delivered, or until timeout elapses.

Awaited from Backend::join so records reported just before shutdown are not lost.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl ChangeStream for NoopStream

Source§

impl<P> ChangeStream for CostTrackerStream<P>
where P: Producer + Clone + Send + Sync + 'static, P::Error: Into<BoxError> + Send + 'static,