Module skytable::pool

source ·
Expand description

§Connection pooling

This module provides ways to create connection pools. For async connections we use bb8 while for sync connections we used r2d2.

§Examples

§Creating an async pool

use skytable::{pool, Config};

const POOL_SIZE: u32 = 32; // we'll have atmost 32 connections in the pool
async fn pool() {
    let pool = pool::get_async(POOL_SIZE, Config::new_default("username", "password")).await.unwrap();
    let mut db = pool.get().await.unwrap();
}

§Creating a async pool

use skytable::{pool, Config};

const POOL_SIZE: u32 = 32; // we'll have atmost 32 connections in the pool
fn pool() {
    let pool = pool::get(POOL_SIZE, Config::new_default("username", "password")).unwrap();
    let mut db = pool.get().unwrap();
}

To create a pool of TLS connections you can use the get_tls and get_tls_async methods, passing a PEM certificate as a string.

Structs§

Functions§

  • Returns a TCP (skyhash/TCP) connection pool using r2d2’s default settings and the given maximum pool size
  • Returns an async TCP (skyhash/TCP) connection pool using bb8’s default settings and the given maximum pool size
  • Returns a TLS (skyhash/TLS) connection pool using r2d2’s default settings and the given maximum pool size
  • Returns an async TLS (skyhash/TCP) connection pool using bb8’s default settings and the given maximum pool size