buildgrid.server.cas.storage.storage_abc module

StorageABC

The abstract base class for storage providers.

buildgrid.server.cas.storage.storage_abc.create_write_session(digest: Digest) IO[bytes]

Return a file-like object to which a blob’s contents could be written.

For large files, to avoid excess memory usage, upload to temporary file. For small files we can work in memory for performance.

class buildgrid.server.cas.storage.storage_abc.StorageABC

Bases: ABC

start() None
stop() None
abstract has_blob(digest: Digest) bool

Return True if the blob with the given instance/digest exists.

abstract get_blob(digest: Digest) IO[bytes] | None

Return a file-like object containing the blob. Most implementations will read the entire file into memory and return a BytesIO object. Eventually this should be corrected to handle files which cannot fit into memory.

The file-like object must be readable and seekable.

If the blob isn’t present in storage, return None.

abstract delete_blob(digest: Digest) None

Delete the blob from storage if it’s present.

abstract commit_write(digest: Digest, write_session: IO[bytes]) None

Store the contents for a digest.

The storage object is not responsible for verifying that the data written to the write_session actually matches the digest. The caller must do that.

bulk_delete(digests: List[Digest]) List[str]

Delete a list of blobs from storage.

missing_blobs(digests: List[Digest]) List[Digest]

Return a container containing the blobs not present in CAS.

bulk_update_blobs(blobs: List[Tuple[Digest, bytes]]) List[Status]

Given a container of (digest, value) tuples, add all the blobs to CAS. Return a list of Status objects corresponding to the result of uploading each of the blobs.

Unlike in commit_write, the storage object will verify that each of the digests matches the provided data.

bulk_read_blobs(digests: List[Digest]) Dict[str, bytes]

Given an iterable container of digests, return a {hash: file-like object} dictionary corresponding to the blobs represented by the input digests.

Each file-like object must be readable and seekable.

put_message(message: MessageType) Digest

Store the given Protobuf message in CAS, returning its digest.

get_message(digest: Digest, message_type: Type[M]) M | None

Retrieve the Protobuf message with the given digest and type from CAS. If the blob is not present, returns None.

is_cleanup_enabled() bool
property instance_name: str | None
set_instance_name(instance_name: str) None
hash_type() int
max_batch_total_size_bytes() int
get_capabilities() CacheCapabilities