Expand description
Connection pooling
This module provides utilities to use connection pooling. As we already know, it is far more efficient to maintain a number of live connections to a database and share them across multiple “worker threads”, using a “connection pool” because creating individual connections whenever a worker receives a task is slow while maintaining a connection per worker might be cumbersome to implement.
To provide connection pooling, we use r2d2
for a sync connection pool while we use
bb8
to provide an async connection pool.
Sync usage
Example usage for TLS and non-TLS connection pools are given below.
use skytable::pool::{ConnectionManager, Pool, TlsPool};
use skytable::sync::{Connection, TlsConnection};
// non-TLS (TCP pool)
let notls_manager = ConnectionManager::new_notls("127.0.0.1".into(), 2003);
let notls_pool = Pool::builder()
.max_size(10)
.build(notls_manager)
.unwrap();
// TLS pool
let tls_manager = ConnectionManager::new_tls(
"127.0.0.1".into(), 2003, "cert.pem".into()
);
let notls_pool = TlsPool::builder()
.max_size(10)
.build(tls_manager)
.unwrap();
Async usage
Example usage for TLS and non-TLS connection pools are given below.
use skytable::pool::{ConnectionManager, AsyncPool, AsyncTlsPool};
use skytable::aio::{Connection, TlsConnection};
async fn run() {
// non-TLS (TCP pool)
let notls_manager = ConnectionManager::new_notls("127.0.0.1".into(), 2003);
let notls_pool = AsyncPool::builder()
.max_size(10)
.build(notls_manager)
.await
.unwrap();
// TLS pool
let tls_manager = ConnectionManager::new_tls(
"127.0.0.1".into(), 2003, "cert.pem".into()
);
let notls_pool = AsyncTlsPool::builder()
.max_size(10)
.build(tls_manager)
.await
.unwrap();
}
Structs
A ConnectionManager
for connection pools. See the module level documentation
for examples and more information
Enums
Type Definitions
An asynchronous non-TLS connection pool to Skytable
aio
and (aio-ssl
or aio-sslv
)An asynchronous TLS connection pool to Skytable
A non-TLS connection pool to Skytable
sync
and (ssl
or sslv
)A TLS connection pool to Skytable