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
impl CacheAgent
Sourcepub fn new(cache_dir: impl Into<PathBuf>, version: impl Into<Arc<str>>) -> Self
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.
Sourcepub fn new_remote(
cache_dir: impl Into<PathBuf>,
version: impl Into<Arc<str>>,
remote: AgentRemoteCache,
) -> Self
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.
Sourcepub fn new_remote_with_download_limit(
cache_dir: impl Into<PathBuf>,
version: impl Into<Arc<str>>,
remote: AgentRemoteCache,
max_remote_download_bytes: u64,
) -> Self
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.
Sourcepub fn with_observer(self, observer: Arc<dyn AgentEventObserver>) -> Self
pub fn with_observer(self, observer: Arc<dyn AgentEventObserver>) -> Self
Report each accounted cache decision to observer as it happens.
Sourcepub async fn begin_task(&self, task: &str) -> Result<String>
pub async fn begin_task(&self, task: &str) -> Result<String>
Load the last committed action manifest for a task into this session.
Sourcepub async fn prefetch_task(&self, task: &str) -> Result<String>
pub async fn prefetch_task(&self, task: &str) -> Result<String>
Load a task and finish its prefetch, surfacing remote lookup failures.
Sourcepub async fn cancel_prefetches(&self)
pub async fn cancel_prefetches(&self)
Cancel speculative downloads before the owning session exits.
Sourcepub async fn wait_for_uploads(&self)
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.
Sourcepub async fn commit_task(&self, run: &str) -> Result<()>
pub async fn commit_task(&self, run: &str) -> Result<()>
Atomically publish the completed actions collected by a task run.
Sourcepub async fn commit_task_actions(
&self,
run: &str,
) -> Result<Vec<ActionPrediction>>
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.
Sourcepub fn stats(&self) -> AgentStats
pub fn stats(&self) -> AgentStats
Return a snapshot of this session’s cache activity.
Sourcepub async fn handle_requests(
&self,
requests: impl IntoIterator<Item = AgentRequest>,
) -> Vec<AgentResponse>
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.
Sourcepub async fn handle_connection<S>(&self, stream: S) -> Result<()>
pub async fn handle_connection<S>(&self, stream: S) -> Result<()>
Serve newline-delimited protocol requests on an authenticated session stream.
Trait Implementations§
Source§impl Clone for CacheAgent
impl Clone for CacheAgent
Source§fn clone(&self) -> CacheAgent
fn clone(&self) -> CacheAgent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more