fn start_filling(&mut self) {
        if self.is_empty() {
            // If the pool is empty, it might mean that the node is not alive.
            // It is more likely than not that the next connection attempt will
            // fail, so there is no use in opening more than one connection now.
            trace!(
                "[{}] Will open the first connection to the node",
                self.address
            );
            self.start_opening_connection(None);
            return;
        }

        if self.can_use_shard_aware_port() {
            // Only use the shard-aware port if we have a PerShard strategy
            if let PoolSize::PerShard(target) = self.pool_config.pool_size {
                // Try to fill up each shard up to `target` connections
                for (shard_id, shard_conns) in self.conns.iter().enumerate() {
                    let to_open_count = target.get().saturating_sub(shard_conns.len());
                    if to_open_count == 0 {
                        continue;
                    }
                    trace!(
                        "[{}] Will open {} connections to shard {}",
                        self.address,
                        to_open_count,
                        shard_id,
                    );
                    for _ in 0..to_open_count {
                        self.start_opening_connection(Some(shard_id as Shard));
                    }
                }
                return;
            }
        }
        // Calculate how many more connections we need to open in order
        // to achieve the target connection count.
        let to_open_count = match self.pool_config.pool_size {
            PoolSize::PerHost(target) => {
                target.get().saturating_sub(self.active_connection_count())
            }
            PoolSize::PerShard(target) => self
                .conns
                .iter()
                .map(|conns| target.get().saturating_sub(conns.len()))
                .sum::<usize>(),
        };
        // When connecting to Scylla through non-shard-aware port,
        // Scylla alone will choose shards for us. We hope that
        // they will distribute across shards in the way we want,
        // but we have no guarantee, so we might have to retry
        // connecting later.
        trace!(
            "[{}] Will open {} non-shard-aware connections",
            self.address,
            to_open_count,
        );
        for _ in 0..to_open_count {
            self.start_opening_connection(None);
        }
    }
// Begins opening a number of connections in order to fill the connection pool.
// Futures which open the connections are pushed to the `ready_connections`
// FuturesUnordered structure, and their results are processed in the main loop.
Begins opening a number of connections in order to fill the connection pool.
Futures which open the connections are pushed to the `ready_connections`
FuturesUnordered structure, and their results are processed in the main loop.
Begins opening a number of connections in order to fill the connection pool . Futures which open the connections are pushed to the ` ready_connections ` FuturesUnordered structure and their results are processed in the main loop .
fn start_filling(&mut self) {
        if self.is_empty() {
            // If the pool is empty, it might mean that the node is not alive.
            // It is more likely than not that the next connection attempt will
            // fail, so there is no use in opening more than one connection now.
            trace!(
                "[{}] Will open the first connection to the node",
                self.address
            );
            self.start_opening_connection(None);
            return;
        }
        if self.can_use_shard_aware_port() {
            // Only use the shard-aware port if we have a PerShard strategy
            if let PoolSize::PerShard(target) = self.pool_config.pool_size {
                // Try to fill up each shard up to `target` connections
                for (shard_id, shard_conns) in self.conns.iter().enumerate() {
                    let to_open_count = target.get().saturating_sub(shard_conns.len());
                    if to_open_count == 0 {
                        continue;
                    }
                    trace!(
                        "[{}] Will open {} connections to shard {}",
                        self.address,
                        to_open_count,
                        shard_id,
                    );
                    for _ in 0..to_open_count {
                        self.start_opening_connection(Some(shard_id as Shard));
                    }
                }
                return;
            }
        }
        // Calculate how many more connections we need to open in order
        // to achieve the target connection count.
        let to_open_count = match self.pool_config.pool_size {
            PoolSize::PerHost(target) => {
                target.get().saturating_sub(self.active_connection_count())
            }
            PoolSize::PerShard(target) => self
                .conns
                .iter()
                .map(|conns| target.get().saturating_sub(conns.len()))
                .sum::<usize>(),
        };
        // When connecting to Scylla through non-shard-aware port,
        // Scylla alone will choose shards for us. We hope that
        // they will distribute across shards in the way we want,
        // but we have no guarantee, so we might have to retry
        // connecting later.
        trace!(
            "[{}] Will open {} non-shard-aware connections",
            self.address,
            to_open_count,
        );
        for _ in 0..to_open_count {
            self.start_opening_connection(None);
        }
    }
fn start_filling ( & mut self ) { if self . is_empty ( ) { // If the pool is empty, it might mean that the node is not alive. // It is more likely than not that the next connection attempt will // fail, so there is no use in opening more than one connection now. trace ! ( " " self address ) ; self . start_opening_connection ( None ) ; return ; } if self . can_use_shard_aware_port ( ) { // Only use the shard-aware port if we have a PerShard strategy if let PoolSize :: PerShard ( target ) = self . pool_config . pool_size { // Try to fill up each shard up to `target` connections for ( shard_id , shard_conns ) in self . conns . iter ( ) . enumerate ( ) { let to_open_count = target . get ( ) . saturating_sub ( shard_conns . len ( ) ) ; if to_open_count == 0 { continue ; } trace ! ( " " self address to_open_count shard_id ) ; for _ in 0 .. to_open_count { self . start_opening_connection ( Some ( shard_id as Shard ) ) ; } } return ; } } // Calculate how many more connections we need to open in order // to achieve the target connection count. let to_open_count = match self . pool_config . pool_size { PoolSize :: PerHost ( target ) => { target . get ( ) . saturating_sub ( self . active_connection_count ( ) ) } PoolSize :: PerShard ( target ) => self . conns . iter ( ) . map ( | conns | target . get ( ) . saturating_sub ( conns . len ( ) ) ) . sum :: < usize > ( ) , } ; // When connecting to Scylla through non-shard-aware port, // Scylla alone will choose shards for us. We hope that // they will distribute across shards in the way we want, // but we have no guarantee, so we might have to retry // connecting later. trace ! ( " " self address to_open_count ) ; for _ in 0 .. to_open_count { self . start_opening_connection ( None ) ; } }
Begins opening a number of connections in order to fill the connection pool.
Begins opening a number of connections in order to fill the connection pool .
&mut self
&mut self