Phase 9 R1: RepoEnsure — peer RPC + aggregator fan-out (#106)
Build with clawstor cache / Cargo build (clawstor-cached) (push) Failing after 25s
Build with clawstor cache / Cargo build (clawstor-cached) (push) Failing after 25s
This commit was merged in pull request #106.
This commit is contained in:
@@ -192,6 +192,43 @@ pub async fn call_dashboard_storage(conn: &Connection) -> Result<DashboardStorag
|
||||
serde_json::from_slice(&reply).context("decoding DashboardStorageReply JSON")
|
||||
}
|
||||
|
||||
/// Phase 9 R1b: convenience wrapper for [`Method::RepoEnsure`].
|
||||
/// Materializes `(url, git_ref)` on the connected peer under the
|
||||
/// caller-provided workspace namespace and returns the resulting
|
||||
/// on-disk path + head sha. Cached reply = the checkout was already
|
||||
/// present with a valid `.git`.
|
||||
pub async fn call_repo_ensure(
|
||||
conn: &Connection,
|
||||
req: &crate::cluster::repo_ensure::RepoEnsureRequest,
|
||||
) -> Result<crate::cluster::repo_ensure::RepoEnsureReply> {
|
||||
let payload = serde_json::to_vec(req).context("encoding RepoEnsureRequest")?;
|
||||
let reply = rpc_call(conn, Method::RepoEnsure, &payload).await?;
|
||||
if reply.len() == 1 {
|
||||
if let Some(code) = decode_error(reply[0]) {
|
||||
bail!("peer replied with error: {}", code.describe());
|
||||
}
|
||||
}
|
||||
serde_json::from_slice(&reply).context("decoding RepoEnsureReply JSON")
|
||||
}
|
||||
|
||||
/// Phase 9 R1b: convenience wrapper for [`Method::RepoRelease`].
|
||||
/// Removes the on-disk checkout for `(url, git_ref)` under the
|
||||
/// caller's workspace. `removed=false` when nothing was on disk to
|
||||
/// begin with (still `Ok`).
|
||||
pub async fn call_repo_release(
|
||||
conn: &Connection,
|
||||
req: &crate::cluster::repo_ensure::RepoReleaseRequest,
|
||||
) -> Result<crate::cluster::repo_ensure::RepoReleaseReply> {
|
||||
let payload = serde_json::to_vec(req).context("encoding RepoReleaseRequest")?;
|
||||
let reply = rpc_call(conn, Method::RepoRelease, &payload).await?;
|
||||
if reply.len() == 1 {
|
||||
if let Some(code) = decode_error(reply[0]) {
|
||||
bail!("peer replied with error: {}", code.describe());
|
||||
}
|
||||
}
|
||||
serde_json::from_slice(&reply).context("decoding RepoReleaseReply JSON")
|
||||
}
|
||||
|
||||
/// Recognise a single-byte reply as one of our error codes. Returns
|
||||
/// `None` for any other single-byte value (which is a valid reply,
|
||||
/// just an unusually short one).
|
||||
|
||||
Reference in New Issue
Block a user