buildgrid.server.cas.storage.size_differentiated module

SizeDifferentiatedStorage

A storage provider which passes requests to other storage providers based on the size of the blob being requested.

class buildgrid.server.cas.storage.size_differentiated.SizeDifferentiatedStorage(storages: List[MutableMapping[str, Union[int, buildgrid.server.cas.storage.storage_abc.StorageABC]]], fallback: buildgrid.server.cas.storage.storage_abc.StorageABC)

Bases: buildgrid.server.cas.storage.storage_abc.StorageABC

has_blob(digest: build.bazel.remote.execution.v2.remote_execution_pb2.Digest) → bool

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

get_blob(digest: build.bazel.remote.execution.v2.remote_execution_pb2.Digest) → io.IOBase

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.

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

delete_blob(digest: build.bazel.remote.execution.v2.remote_execution_pb2.Digest)

Delete the blob from storage if it’s present.

begin_write(digest: build.bazel.remote.execution.v2.remote_execution_pb2.Digest) → io.IOBase

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

commit_write(digest: build.bazel.remote.execution.v2.remote_execution_pb2.Digest, write_session: io.IOBase)

Commit the write operation. write_session must be an object returned by begin_write.

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.