pub trait PrefetchFetcher: Send + Sync {
// Required methods
fn contains_flat(&self, namespace: &str, key: &str) -> bool;
fn fetch_block(
&self,
namespace: &str,
key: &str,
) -> Result<Option<u64>, String>;
}Expand description
Materialization surface for v2 prefetch. The worker holds an
Arc<dyn PrefetchFetcher> so the algorithm crate can issue GETs
without the block_prefetch module depending on the embed module’s
generic WombatKVKvStore<S> shape.
Implementations must be cheap to call (contains_flat should be a
single filesystem stat) and fetch_block must populate the local
flat tier on success, the whole point of v2 is to warm the flat
cache before request time.
Required Methods§
Sourcefn contains_flat(&self, namespace: &str, key: &str) -> bool
fn contains_flat(&self, namespace: &str, key: &str) -> bool
Returns true if the block is already materialized in the local flat tier. The worker skips already-flat blocks to keep cycle cost bounded.
Sourcefn fetch_block(&self, namespace: &str, key: &str) -> Result<Option<u64>, String>
fn fetch_block(&self, namespace: &str, key: &str) -> Result<Option<u64>, String>
Fetch the block. Returns Ok(Some(bytes_len)) on hit (and the
implementation populates flat/foyer), Ok(None) on miss, and
Err(message) on backend error. The worker logs+continues on
error; one bad block does not stop the cycle.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".