Skip to main content

CacheAgent

Struct CacheAgent 

Source
pub struct CacheAgent { /* private fields */ }
Expand description

Shared state for an agent hosted by the process that owns a build session.

Transport listeners deliberately live in the embedder so the session lifecycle owns them. This type only contains ecosystem-independent CAS and protocol logic.

Implementations§

Source§

impl CacheAgent

Source

pub fn new(cache_dir: impl Into<PathBuf>, version: impl Into<Arc<str>>) -> Self

Create an agent backed by the cache rooted at cache_dir.

Source

pub fn new_remote( cache_dir: impl Into<PathBuf>, version: impl Into<Arc<str>>, remote: AgentRemoteCache, ) -> Self

Create an agent with local-first access to a remote action cache.

Source

pub fn new_remote_with_download_limit( cache_dir: impl Into<PathBuf>, version: impl Into<Arc<str>>, remote: AgentRemoteCache, max_remote_download_bytes: u64, ) -> Self

Create a remote agent with a cumulative download budget for the session.

Source

pub fn with_observer(self, observer: Arc<dyn AgentEventObserver>) -> Self

Report each accounted cache decision to observer as it happens.

Source

pub async fn begin_task(&self, task: &str) -> Result<String>

Load the last committed action manifest for a task into this session.

Source

pub async fn prefetch_task(&self, task: &str) -> Result<String>

Load a task and finish its prefetch, surfacing remote lookup failures.

Source

pub async fn cancel_prefetches(&self)

Cancel speculative downloads before the owning session exits.

Source

pub async fn wait_for_uploads(&self)

Publish everything a build queued, before the session stops.

Store requests return once an object is durable locally, so at this point the remote cache may still be behind the local one. Uploads run on the session’s runtime and are abandoned if it goes away, so a session that wants them published has to wait here.

Source

pub async fn commit_task(&self, run: &str) -> Result<()>

Atomically publish the completed actions collected by a task run.

Source

pub async fn commit_task_actions( &self, run: &str, ) -> Result<Vec<ActionPrediction>>

Publish a task run and return exactly the predictions completed by it.

The persisted task manifest also carries predictions inherited from earlier runs. Callers that need a receipt for this one run must not mistake that cumulative manifest for the work the run completed.

Source

pub fn stats(&self) -> AgentStats

Return a snapshot of this session’s cache activity.

Source

pub async fn handle_requests( &self, requests: impl IntoIterator<Item = AgentRequest>, ) -> Vec<AgentResponse>

Handle requests without a transport connection.

Persistent wrappers use this entry point when Cargo invokes mbx outside an orchestrated session. It intentionally has the same response semantics as Self::handle_connection, while leaving framing and the version handshake to callers that actually cross a process boundary.

Source

pub async fn handle_connection<S>(&self, stream: S) -> Result<()>
where S: AsyncRead + AsyncWrite + Unpin,

Serve newline-delimited protocol requests on an authenticated session stream.

Trait Implementations§

Source§

impl Clone for CacheAgent

Source§

fn clone(&self) -> CacheAgent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more