/// connect to sc if can't connect try until we succeed
/// or if we received termination message
connect to sc if can't connect try until we succeed
or if we received termination message
connect to sc if can ' t connect try until we succeed or if we received termination message
async fn create_socket_to_sc(&mut self) -> Option<KfSocket> {
        let spu_id = self.ctx.local_spu_id();
        let sc_endpoint = self.ctx.config().sc_endpoint().to_string();
         debug!("trying to resolve sc endpoint: {}",sc_endpoint);
        let wait_interval = self.ctx.config().sc_retry_ms;
        loop {
            trace!(
                "trying to create socket to sc: {:#?} for spu: {}",
                sc_endpoint,
                spu_id
            );
            let connect_future = KfSocket::connect(&sc_endpoint);
            select! {
                socket_res = connect_future.fuse() => {
                    match socket_res {
                        Ok(socket) => {
                            debug!("connected to sc for spu: {}",spu_id);
                            return Some(socket)
                        }
                        Err(err) => warn!("error connecting to sc: {}",err)
                    }
                    trace!("sleeping {} ms to connect to sc: {}",wait_interval,spu_id);
                    sleep(Duration::from_millis(wait_interval as u64)).await;
                },
                _ = self.termination_receiver.next() => {
                    info!("termination message received");
                    return None
                }
            }
        }
    }
async fn create_socket_to_sc ( & mut self ) -> Option < KfSocket > { let spu_id = self . ctx . local_spu_id ( ) ; let sc_endpoint = self . ctx . config ( ) . sc_endpoint ( ) . to_string ( ) ; debug ! ( " " sc_endpoint ) ; let wait_interval = self . ctx . config ( ) . sc_retry_ms ; loop { trace ! ( " " sc_endpoint spu_id ) ; let connect_future = KfSocket :: connect ( & sc_endpoint ) ; select ! { socket_res connect_future fuse ( ) { match socket_res { Ok ( socket ) { debug ( " " spu_id ) return Some ( socket ) } Err ( err ) warn ( " " err ) } trace ( " " wait_interval spu_id ) sleep ( Duration from_millis ( wait_interval as u64 ) ) await } self termination_receiver next ( ) { info ( " " ) return None } } } }
connect to sc if can't connect try until we succeed
or if we received termination message
connect to sc if can ' t connect try until we succeed or if we received termination message
&mut self