pub trait ObjectBlockOps: Send + Sync {
// Required methods
fn has_blocks(
&self,
keys: Vec<SequenceHash>,
) -> BoxFuture<'static, Vec<(SequenceHash, Option<usize>)>>;
fn put_blocks(
&self,
keys: Vec<SequenceHash>,
src_layout: LogicalLayoutHandle,
block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>;
fn get_blocks(
&self,
keys: Vec<SequenceHash>,
dst_layout: LogicalLayoutHandle,
block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>;
// Provided methods
fn put_blocks_with_layout(
&self,
keys: Vec<SequenceHash>,
_layout: PhysicalLayout,
_block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>> { ... }
fn get_blocks_with_layout(
&self,
keys: Vec<SequenceHash>,
_layout: PhysicalLayout,
_block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>> { ... }
}Expand description
Unified object block operations trait.
This trait provides high-level operations for storing and retrieving KV cache blocks in object storage (e.g., S3, MinIO).
Uses LogicalLayoutHandle to identify source/destination layouts. In distributed
mode, workers resolve the logical handle to their own physical layouts. This allows
the leader (which doesn’t have physical layouts) to use the same trait.
Uses 'static BoxFuture for runtime flexibility - implementations clone/Arc
what they need from self. Takes owned Vecs for simplicity; keys are returned
in results so callers can correlate success/failure.
Implemented by:
S3ObjectBlockClient- direct S3 operations (has_blocks only; put/get require physical layout)DirectWorker- resolves logical handle to physical layout, then delegatesCoordinatedWorker- delegates to inner workerLeaderObjectClient- coordinates workers for distributed uploads
Required Methods§
Sourcefn has_blocks(
&self,
keys: Vec<SequenceHash>,
) -> BoxFuture<'static, Vec<(SequenceHash, Option<usize>)>>
fn has_blocks( &self, keys: Vec<SequenceHash>, ) -> BoxFuture<'static, Vec<(SequenceHash, Option<usize>)>>
Check if blocks exist in object storage.
Returns a vector of (hash, size_option) pairs where:
- Some(size) indicates the block exists with the given size in bytes
- None indicates the block does not exist or an error occurred
Sourcefn put_blocks(
&self,
keys: Vec<SequenceHash>,
src_layout: LogicalLayoutHandle,
block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
fn put_blocks( &self, keys: Vec<SequenceHash>, src_layout: LogicalLayoutHandle, block_ids: Vec<BlockId>, ) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
Put blocks to object storage.
§Arguments
keys- Sequence hashes identifying each blocksrc_layout- Logical layout handle identifying the source (workers resolve to physical)block_ids- Block IDs within the layout to upload
Returns a vector of results for each block:
- Ok(hash) indicates the block was successfully stored
- Err(hash) indicates the block failed to store
§Note
For S3ObjectBlockClient, this will error - use put_blocks_with_layout instead.
Workers should resolve the logical handle to their physical layout first.
Sourcefn get_blocks(
&self,
keys: Vec<SequenceHash>,
dst_layout: LogicalLayoutHandle,
block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
fn get_blocks( &self, keys: Vec<SequenceHash>, dst_layout: LogicalLayoutHandle, block_ids: Vec<BlockId>, ) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
Get blocks from object storage.
§Arguments
keys- Sequence hashes identifying each blockdst_layout- Logical layout handle identifying the destination (workers resolve to physical)block_ids- Block IDs within the layout to download into
Returns a vector of results for each block:
- Ok(hash) indicates the block was successfully retrieved
- Err(hash) indicates the block failed to retrieve
§Note
For S3ObjectBlockClient, this will error - use get_blocks_with_layout instead.
Workers should resolve the logical handle to their physical layout first.
Provided Methods§
Sourcefn put_blocks_with_layout(
&self,
keys: Vec<SequenceHash>,
_layout: PhysicalLayout,
_block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
fn put_blocks_with_layout( &self, keys: Vec<SequenceHash>, _layout: PhysicalLayout, _block_ids: Vec<BlockId>, ) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
Put blocks to object storage using a resolved physical layout.
This method is called by workers after resolving a logical handle to
their physical layout. The default implementation errors; storage backends
like S3ObjectBlockClient override this with actual upload logic.
§Arguments
keys- Sequence hashes identifying each blocklayout- Physical layout containing the block datablock_ids- Block IDs within the layout to upload
Sourcefn get_blocks_with_layout(
&self,
keys: Vec<SequenceHash>,
_layout: PhysicalLayout,
_block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
fn get_blocks_with_layout( &self, keys: Vec<SequenceHash>, _layout: PhysicalLayout, _block_ids: Vec<BlockId>, ) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
Get blocks from object storage into a resolved physical layout.
This method is called by workers after resolving a logical handle to
their physical layout. The default implementation errors; storage backends
like S3ObjectBlockClient override this with actual download logic.
§Arguments
keys- Sequence hashes identifying each blocklayout- Physical layout to write the block data intoblock_ids- Block IDs within the layout to download into
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".