(
client: &mut crate::tls::GrpcClient,
name: &str,
)
| 2946 | } |
| 2947 | |
| 2948 | async 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)] |
| 2984 | struct ForwardTcpConnectionError { |
no test coverage detected