MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / fetch_ready_sandbox_for_forward

Function fetch_ready_sandbox_for_forward

crates/openshell-cli/src/run.rs:2948–2981  ·  view source on GitHub ↗
(
    client: &mut crate::tls::GrpcClient,
    name: &str,
)

Source from the content-addressed store, hash-verified

2946}
2947
2948async fn fetch_ready_sandbox_for_forward(
2949 client: &mut crate::tls::GrpcClient,
2950 name: &str,
2951) -> Result<Sandbox> {
2952 let response = match client
2953 .get_sandbox(GetSandboxRequest {
2954 name: name.to_string(),
2955 })
2956 .await
2957 {
2958 Ok(response) => response,
2959 Err(status) if status.code() == Code::NotFound => {
2960 return Err(miette::miette!(
2961 "sandbox '{name}' no longer exists; stopping service forward"
2962 ));
2963 }
2964 Err(status) => return Err(status).into_diagnostic(),
2965 };
2966
2967 let sandbox = response
2968 .into_inner()
2969 .sandbox
2970 .ok_or_else(|| miette::miette!("sandbox '{name}' not found"))?;
2971
2972 if SandboxPhase::try_from(sandbox.phase()) != Ok(SandboxPhase::Ready) {
2973 return Err(miette::miette!(
2974 "sandbox '{}' is no longer ready (phase: {}); stopping service forward",
2975 name,
2976 phase_name(sandbox.phase())
2977 ));
2978 }
2979
2980 Ok(sandbox)
2981}
2982
2983#[derive(Debug)]
2984struct ForwardTcpConnectionError {

Callers 1

service_forward_tcpFunction · 0.85

Calls 3

codeMethod · 0.80
get_sandboxMethod · 0.45
phaseMethod · 0.45

Tested by

no test coverage detected