pub struct RemoteCacheClient { /* private fields */ }Expand description
A client for a remote mbx cache.
The client validates digests, response sizes, media types, and redirects at the protocol boundary. It is safe to share between asynchronous tasks.
Which service is on the other end is not part of this type’s contract. A cache server speaks the full protocol; an object store answers the same lookups without the extensions built on top of it, and reports that by declining them rather than by failing.
Implementations§
Source§impl RemoteCacheClient
impl RemoteCacheClient
Sourcepub fn new(config: RemoteCacheConfig) -> Result<Self>
pub fn new(config: RemoteCacheConfig) -> Result<Self>
Construct a client and validate its URL and authentication settings.
Sourcepub fn new_s3(config: S3RemoteCacheConfig) -> Result<Self>
pub fn new_s3(config: S3RemoteCacheConfig) -> Result<Self>
Construct a client backed directly by an S3-compatible object store.
The store answers the same lookups a cache server does, without the
extensions built on top of the protocol. See S3RemoteCacheConfig.
Sourcepub async fn check_connection(&self) -> Result<()>
pub async fn check_connection(&self) -> Result<()>
Connect to the service, authenticate, and negotiate protocol capabilities.
This performs no cache reads or writes. It is intended for diagnostics that need to distinguish a valid client configuration from a reachable, compatible remote cache.
Sourcepub async fn get_blob_pack(
&self,
digests: &[CacheDigest],
staging_dir: &Path,
) -> Result<Option<RemoteBlobPack>>
pub async fn get_blob_pack( &self, digests: &[CacheDigest], staging_dir: &Path, ) -> Result<Option<RemoteBlobPack>>
Download verified CAS objects using the server’s negotiated blob-pack extension.
None means the service does not support blob packs. Objects omitted by a
supported server are absent from blobs, so callers can retry them through
the ordinary single-blob endpoint.
Sourcepub async fn get_action_result(
&self,
action: &CacheDigest,
) -> Result<Option<RemoteActionResult>>
pub async fn get_action_result( &self, action: &CacheDigest, ) -> Result<Option<RemoteActionResult>>
Fetch and validate an action-result record, returning None on a miss.
Sourcepub async fn get_action_results(
&self,
actions: &[CacheDigest],
) -> Result<Option<Vec<RemoteActionResult>>>
pub async fn get_action_results( &self, actions: &[CacheDigest], ) -> Result<Option<Vec<RemoteActionResult>>>
Look up several action results in one request.
None means the service does not answer batched lookups, leaving the
caller to ask for each action individually. The response carries only the
results the service holds, in no particular order, so each record is bound
to its request by the action digest it names rather than by position.
Sourcepub async fn put_action_result(&self, result: &RemoteActionResult) -> Result<()>
pub async fn put_action_result(&self, result: &RemoteActionResult) -> Result<()>
Canonically serialize and store an action-result record.
Sourcepub async fn join_action_promise(
&self,
invocation: &CacheDigest,
adapter: &str,
) -> Result<Option<ActionPromiseState>>
pub async fn join_action_promise( &self, invocation: &CacheDigest, adapter: &str, ) -> Result<Option<ActionPromiseState>>
Atomically join or claim a server-wide compilation promise.
None means this backend does not support ephemeral coordination.
Sourcepub async fn complete_action_promise(
&self,
invocation: &CacheDigest,
completion: &ActionPromiseCompletion,
) -> Result<bool>
pub async fn complete_action_promise( &self, invocation: &CacheDigest, completion: &ActionPromiseCompletion, ) -> Result<bool>
Complete a claimed promise after its action result has been published.
false means this backend does not support ephemeral coordination.
Sourcepub async fn get_action_manifest(
&self,
key: &CacheDigest,
) -> Result<Option<RemoteActionManifest>>
pub async fn get_action_manifest( &self, key: &CacheDigest, ) -> Result<Option<RemoteActionManifest>>
Fetch a task action manifest and the entity tag needed to update it.
Sourcepub async fn put_action_manifest(
&self,
key: &CacheDigest,
bytes: &[u8],
expected_etag: Option<&str>,
) -> Result<ManifestPutOutcome>
pub async fn put_action_manifest( &self, key: &CacheDigest, bytes: &[u8], expected_etag: Option<&str>, ) -> Result<ManifestPutOutcome>
Store a task action manifest, optionally requiring an entity-tag match.
Sourcepub async fn get_blob(
&self,
digest: &CacheDigest,
media_type: &'static str,
) -> Result<Vec<u8>>
pub async fn get_blob( &self, digest: &CacheDigest, media_type: &'static str, ) -> Result<Vec<u8>>
Download a small blob into memory and verify its digest.
Sourcepub async fn get_blob_file(
&self,
digest: &CacheDigest,
staging_dir: &Path,
) -> Result<NamedTempFile>
pub async fn get_blob_file( &self, digest: &CacheDigest, staging_dir: &Path, ) -> Result<NamedTempFile>
Download a blob to a temporary file and verify its digest.
Sourcepub async fn put_blob_pack(
&self,
uploads: &[BlobUpload],
) -> Result<Option<BlobPackReceipt>>
pub async fn put_blob_pack( &self, uploads: &[BlobUpload], ) -> Result<Option<BlobPackReceipt>>
Upload several content-addressed blobs in one framed request.
None means the service does not accept packed uploads, leaving the
caller to send each blob on its own. A rejected pack is reported as an
error and publishes nothing the caller may rely on: a server verifies
each frame as it arrives, so an accepted prefix may exist, but every blob
is content-addressed and storing one twice is not an error.
Sourcepub async fn put_blob(&self, upload: &BlobUpload) -> Result<()>
pub async fn put_blob(&self, upload: &BlobUpload) -> Result<()>
Verify and upload a content-addressed blob.