mobc-reql

Crates.iomobc-reql
lib.rsmobc-reql
version0.6.4
sourcesrc
created_at2021-05-02 23:49:04.603238
updated_at2022-02-12 06:15:05.833316
descriptionRethinkDB support for the mobc connection pool
homepage
repositoryhttps://github.com/rethinkdb/rethinkdb-rs/tree/main/mobc
max_upload_size
id392344
size9,956
Rushmore Mushambi (rushmorem)

documentation

https://docs.rs/mobc-reql

README

mobc-reql

ReQL connection pool implementation

use mobc_reql::{GetSession, Pool, SessionManager};

// Create the session manager
let manager = SessionManager::new(Default::default());

// Pull the rest of your nodes from your cluster. The connection pool
// connects to the node with the lowest latency.
// It is optional but highly recommended. This way, your app will
// continue working even when nodes go up and down.
tokio::spawn(manager.discover_hosts());

// Create the pool
let pool = Pool::builder().max_open(20).build(manager);

// Get a session from the pool
let session = pool.session().await?;

// You can pass a reference of the session to run.
// This allows you to use the same underlying connection for multiple
// queries as long as none of them is a change-feed.
// You can even use just one connection for your entire app, even running
// the queries concurrently.
//
// Change feeds on the other hand, require dedicated connections,
// so for each changefeed you need to grab a new session from the pool.
r.expr("Hello world!").run(&session);
Commit count: 3059

cargo fmt