/// Task that periodically checks if there is a dead connection.
///
/// The interval is defined by CHECK_CONNECTIONS_MSEC.
///
/// If a dead connection is detected, all connections are dropped and
/// it will try to fill the pool with the required amount of connections.
///
Task that periodically checks if there is a dead connection.
The interval is defined by CHECK_CONNECTIONS_MSEC.

If a dead connection is detected, all connections are dropped and
it will try to fill the pool with the required amount of connections.
Task that periodically checks if there is a dead connection . The interval is defined by CHECK_CONNECTIONS_MSEC . If a dead connection is detected all connections are dropped and it will try to fill the pool with the required amount of connections .
fn reconnect_task(&self) {
        let self_copy = self.clone();
        let connections_copy = self.connections.clone();
        tokio::task::spawn(async move {
            loop {
                let dead = self_copy.has_dead_con.load(Ordering::SeqCst);
                if dead {
                    log::error!("Dead connection detected");
                    self_copy.drop_all();
                    log::info!("Reconnecting");
                    let pool_size = self_copy.pool_size.load(Ordering::SeqCst);
                    for _ in 0..pool_size {
                        if let Ok(con) = self_copy.connect().await {
                            let mut cons = connections_copy.lock().unwrap();
                            cons.push_back(con);
                            self_copy.available.fetch_add(1, Ordering::SeqCst);
                        }
                    }
                }
                self_copy.has_dead_con.store(false, Ordering::SeqCst);
                std::thread::sleep(std::time::Duration::from_millis(Self::CHECK_CONNECTIONS_MSEC));
            }
        });
    }
fn reconnect_task ( & self ) { let self_copy = self . clone ( ) ; let connections_copy = self . connections . clone ( ) ; tokio :: task :: spawn ( async move { loop { let dead = self_copy . has_dead_con . load ( Ordering :: SeqCst ) ; if dead { log :: error ! ( " " ) ; self_copy . drop_all ( ) ; log :: info ! ( " " ) ; let pool_size = self_copy . pool_size . load ( Ordering :: SeqCst ) ; for _ in 0 .. pool_size { if let Ok ( con ) = self_copy . connect ( ) . await { let mut cons = connections_copy . lock ( ) . unwrap ( ) ; cons . push_back ( con ) ; self_copy . available . fetch_add ( 1 , Ordering :: SeqCst ) ; } } } self_copy . has_dead_con . store ( false , Ordering :: SeqCst ) ; std :: thread :: sleep ( std :: time :: Duration :: from_millis ( Self :: CHECK_CONNECTIONS_MSEC ) ) ; } } ) ; }
Task that periodically checks if there is a dead connection.
Task that periodically checks if there is a dead connection .
&self