/// Creates a new pool. The given number is the number of connections the
/// pool will hold. The returned pool is already filled with connections
/// and can be used.
///
/// # Params
///
/// * `url`   - Ip address + port of the database server
/// * `count` - Number of connection to store
///
/// # Returns
///
/// New pool containing the given number of connections
///
Creates a new pool. The given number is the number of connections the
pool will hold. The returned pool is already filled with connections
and can be used.
Creates a new pool . The given number is the number of connections the pool will hold . The returned pool is already filled with connections and can be used .
pub async fn new(url: &'static str, count: usize) -> Result<Self, CachemError> {
        let pool = Self {
            available:    Arc::new(AtomicUsize::new(count)),
            pool_size:    Arc::new(AtomicUsize::new(count)),
            has_dead_con: Arc::new(AtomicBool::new(false)),
            connections: Arc::new(Mutex::new(VecDeque::new())),
            url,
        };
        let mut connections = VecDeque::new();
        for _ in 0..count {
            connections.push_back(pool.connect().await?)
        }
        pool.connections.lock().unwrap().extend(connections);
        pool.reconnect_task();
        Ok(pool)
    }
pub async fn new ( url : & ' static str , count : usize ) -> Result < Self , CachemError > { let pool = Self { available : Arc :: new ( AtomicUsize :: new ( count ) ) , pool_size : Arc :: new ( AtomicUsize :: new ( count ) ) , has_dead_con : Arc :: new ( AtomicBool :: new ( false ) ) , connections : Arc :: new ( Mutex :: new ( VecDeque :: new ( ) ) ) , url , } ; let mut connections = VecDeque :: new ( ) ; for _ in 0 .. count { connections . push_back ( pool . connect ( ) . await ? ) } pool . connections . lock ( ) . unwrap ( ) . extend ( connections ) ; pool . reconnect_task ( ) ; Ok ( pool ) }
Creates a new pool.
Creates a new pool .
New pool containing the given number of connections
New pool containing the given number of connections
url
&'static str
count
usize
params
`url`   - Ip address + port of the database server
`count` - Number of connection to store
` url ` - Ip address + port of the database server ` count ` - Number of connection to store