pub async fn validate(&mut self) -> Result<BytesMut, Error> {
        let mut server_infos = Vec::new();

        let stats = self.stats.clone();
        for shard in 0..self.shards() {
            for _ in 0..self.servers(shard) {
                // To keep stats consistent.
                let fake_process_id = 0;

                let connection = match self.get(shard, None, fake_process_id).await {
                    Ok(conn) => conn,
                    Err(err) => {
                        error!("Shard {} down or misconfigured: {:?}", shard, err);
                        continue;
                    }
                };

                let mut proxy = connection.0;
                let address = connection.1;
                let server = &mut *proxy;

                let server_info = server.server_info();

                stats.client_disconnecting(fake_process_id, address.id);

                if server_infos.len() > 0 {
                    // Compare against the last server checked.
                    if server_info != server_infos[server_infos.len() - 1] {
                        warn!(
                            "{:?} has different server configuration than the last server",
                            address
                        );
                    }
                }

                server_infos.push(server_info);
            }
        }

        // TODO: compare server information to make sure
        // all shards are running identical configurations.
        if server_infos.len() == 0 {
            return Err(Error::AllServersDown);
        }

        Ok(server_infos[0].clone())
    }
/// Connect to all shards and grab server information.
/// Return server information we will pass to the clients
/// when they connect.
/// This also warms up the pool for clients that connect when
/// the pooler starts up.
Connect to all shards and grab server information.
Return server information we will pass to the clients
when they connect.
This also warms up the pool for clients that connect when
the pooler starts up.
Connect to all shards and grab server information . Return server information we will pass to the clients when they connect . This also warms up the pool for clients that connect when the pooler starts up .
pub async fn validate(&mut self) -> Result<BytesMut, Error> {
        let mut server_infos = Vec::new();
        let stats = self.stats.clone();
        for shard in 0..self.shards() {
            for _ in 0..self.servers(shard) {
                // To keep stats consistent.
                let fake_process_id = 0;
                let connection = match self.get(shard, None, fake_process_id).await {
                    Ok(conn) => conn,
                    Err(err) => {
                        error!("Shard {} down or misconfigured: {:?}", shard, err);
                        continue;
                    }
                };
                let mut proxy = connection.0;
                let address = connection.1;
                let server = &mut *proxy;
                let server_info = server.server_info();
                stats.client_disconnecting(fake_process_id, address.id);
                if server_infos.len() > 0 {
                    // Compare against the last server checked.
                    if server_info != server_infos[server_infos.len() - 1] {
                        warn!(
                            "{:?} has different server configuration than the last server",
                            address
                        );
                    }
                }
                server_infos.push(server_info);
            }
        }
        // TODO: compare server information to make sure
        // all shards are running identical configurations.
        if server_infos.len() == 0 {
            return Err(Error::AllServersDown);
        }
        Ok(server_infos[0].clone())
    }
pub async fn validate ( & mut self ) -> Result < BytesMut , Error > { let mut server_infos = Vec :: new ( ) ; let stats = self . stats . clone ( ) ; for shard in 0 .. self . shards ( ) { for _ in 0 .. self . servers ( shard ) { // To keep stats consistent. let fake_process_id = 0 ; let connection = match self . get ( shard , None , fake_process_id ) . await { Ok ( conn ) => conn , Err ( err ) => { error ! ( " " shard err ) ; continue ; } } ; let mut proxy = connection . 0 ; let address = connection . 1 ; let server = & mut * proxy ; let server_info = server . server_info ( ) ; stats . client_disconnecting ( fake_process_id , address . id ) ; if server_infos . len ( ) > 0 { // Compare against the last server checked. if server_info != server_infos [ server_infos . len ( ) - 1 ] { warn ! ( " " address ) ; } } server_infos . push ( server_info ) ; } } // TODO: compare server information to make sure // all shards are running identical configurations. if server_infos . len ( ) == 0 { return Err ( Error :: AllServersDown ) ; } Ok ( server_infos [ 0 ] . clone ( ) ) }
Connect to all shards and grab server information.
Connect to all shards and grab server information .
&mut self
&mut self