pub trait Producer {
type Error;
// Required methods
fn send(&self, key: &[u8], payload: Vec<u8>) -> Result<(), Self::Error>;
fn join_blocking(&self, timeout: Duration) -> Result<(), Self::Error>;
// Provided methods
fn join(
&self,
timeout: Duration,
) -> impl Future<Output = Result<(), Self::Error>> + Send + use<Self>
where Self: Sized + Clone + Send + Sync + 'static,
Self::Error: Send + 'static { ... }
fn shared(self) -> SharedProducer
where Self: Sized + Send + Sync + 'static,
Self::Error: Error + Send + Sync + 'static { ... }
}Expand description
Sends serialized inventory records somewhere durable.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn join(
&self,
timeout: Duration,
) -> impl Future<Output = Result<(), Self::Error>> + Send + use<Self>
fn join( &self, timeout: Duration, ) -> impl Future<Output = Result<(), Self::Error>> + Send + use<Self>
Waits for enqueued records to be delivered, or until timeout elapses.
Runs join_blocking on a blocking thread. Returns a future
rather than being async fn so it does not borrow self, which a dyn caller’s
async_trait boxing requires.
Erases this producer’s transport and error type, so one producer can serve several trackers.
use objectstore_inventory_tracker::{InventoryTracker, NoopProducer, Producer};
let producer = NoopProducer.shared();
let tracker = InventoryTracker::new(producer.clone(), "my_gcs_bucket", 1.0);Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".