async fn wait_till_nexus_state(
    cluster: &Cluster,
    nexus_id: &Uuid,
    state: Option<&models::Nexus>,
) -> Option<models::Nexus> {
    let timeout = Duration::from_secs(RECONCILE_TIMEOUT_SECS);
    let client = cluster.rest_v00();
    let nexuses_api = client.nexuses_api();
    let start = std::time::Instant::now();
    loop {
        let nexus = nexuses_api.get_nexus(nexus_id).await;
        match &nexus {
            Ok(nexus) => {
                if let Some(state) = state {
                    if nexus.protocol != models::Protocol::None
                        && state.protocol != models::Protocol::None
                    {
                        return Some(nexus.clone());
                    }
                }
            }
            Err(Error::Response(response))
                if response.status() == StatusCode::NOT_FOUND && state.is_none() =>
            {
                return None;
            }
            _ => {}
        };

        if std::time::Instant::now() > (start + timeout) {
            panic!(
                "Timeout waiting for the nexus to have state: '{:#?}'. Actual: '{:#?}'",
                state, nexus
            );
        }
        tokio::time::sleep(Duration::from_millis(500)).await;
    }
}
/// Wait until the specified nexus state option matches the requested `state`
Wait until the specified nexus state option matches the requested `state`
Wait until the specified nexus state option matches the requested ` state `
async fn wait_till_nexus_state(
    cluster: &Cluster,
    nexus_id: &Uuid,
    state: Option<&models::Nexus>,
) -> Option<models::Nexus> {
    let timeout = Duration::from_secs(RECONCILE_TIMEOUT_SECS);
    let client = cluster.rest_v00();
    let nexuses_api = client.nexuses_api();
    let start = std::time::Instant::now();
    loop {
        let nexus = nexuses_api.get_nexus(nexus_id).await;
        match &nexus {
            Ok(nexus) => {
                if let Some(state) = state {
                    if nexus.protocol != models::Protocol::None
                        && state.protocol != models::Protocol::None
                    {
                        return Some(nexus.clone());
                    }
                }
            }
            Err(Error::Response(response))
                if response.status() == StatusCode::NOT_FOUND && state.is_none() =>
            {
                return None;
            }
            _ => {}
        };
        if std::time::Instant::now() > (start + timeout) {
            panic!(
                "Timeout waiting for the nexus to have state: '{:#?}'. Actual: '{:#?}'",
                state, nexus
            );
        }
        tokio::time::sleep(Duration::from_millis(500)).await;
    }
}
async fn wait_till_nexus_state ( cluster : & Cluster , nexus_id : & Uuid , state : Option < & models :: Nexus > , ) -> Option < models :: Nexus > { let timeout = Duration :: from_secs ( RECONCILE_TIMEOUT_SECS ) ; let client = cluster . rest_v00 ( ) ; let nexuses_api = client . nexuses_api ( ) ; let start = std :: time :: Instant :: now ( ) ; loop { let nexus = nexuses_api . get_nexus ( nexus_id ) . await ; match & nexus { Ok ( nexus ) => { if let Some ( state ) = state { if nexus . protocol != models :: Protocol :: None && state . protocol != models :: Protocol :: None { return Some ( nexus . clone ( ) ) ; } } } Err ( Error :: Response ( response ) ) if response . status ( ) == StatusCode :: NOT_FOUND && state . is_none ( ) => { return None ; } _ => { } } ; if std :: time :: Instant :: now ( ) > ( start + timeout ) { panic ! ( " " state nexus ) ; } tokio :: time :: sleep ( Duration :: from_millis ( 500 ) ) . await ; } }
Wait until the specified nexus state option matches the requested `state`
Wait until the specified nexus state option matches the requested ` state `
cluster
&Cluster
nexus_id
&Uuid
state
Option<&models::Nexus>
cluster
&Cluster
nexus_id
&Uuid
state
Option<&models::Nexus>