/// Try to connect to the NATS server including DNS resolution step if
/// needed.
Try to connect to the NATS server including DNS resolution step if
needed.
Try to connect to the NATS server including DNS resolution step if needed .
async fn connect(&self) -> Result<NatsClient, Error> {
        // Resolve the hostname of the server - nats lib won't do that for us
        let server_ip = match SocketAddr::from_str(&self.server) {
            Ok(_) => self.server.clone(),
            Err(_) => resolve(&self.server).await?,
        };
        debug!("Connecting to the message bus");
        let config = NatsConfigBuilder::default()
            .reconnection_period(self.hb_interval)
            .server(&server_ip)
            .build()
            .map_err(|cause| Error::BuildClient {
                server: self.server.clone(),
                cause,
            })?;
        connect(config).await.map_err(|err| Error::ConnectFailed {
            server: self.server.clone(),
            cause: err,
        })
    }
async fn connect ( & self ) -> Result < NatsClient , Error > { // Resolve the hostname of the server - nats lib won't do that for us let server_ip = match SocketAddr :: from_str ( & self . server ) { Ok ( _ ) => self . server . clone ( ) , Err ( _ ) => resolve ( & self . server ) . await ? , } ; debug ! ( " " ) ; let config = NatsConfigBuilder :: default ( ) . reconnection_period ( self . hb_interval ) . server ( & server_ip ) . build ( ) . map_err ( | cause | Error :: BuildClient { server : self . server . clone ( ) , cause , } ) ? ; connect ( config ) . await . map_err ( | err | Error :: ConnectFailed { server : self . server . clone ( ) , cause : err , } ) }
Try to connect to the NATS server including DNS resolution step if
needed.
Try to connect to the NATS server including DNS resolution step if needed .
&self