Crates.io | picoslon |
lib.rs | picoslon |
version | 0.1.0 |
source | src |
created_at | 2024-01-18 11:06:06.067593 |
updated_at | 2024-01-18 11:06:06.067593 |
description | A postgresql driver for picodata apps. |
homepage | |
repository | https://git.picodata.io/picodata/modules/picoslon |
max_upload_size | |
id | 1104095 |
size | 20,348 |
A postgresql driver for picodata apps. Non blocking, fiber friendly, driven by CBUS. Build over rust-postgres driver.
This client has a similar API as postgres
crate (see docs for more).
Create a client using client builder:
use radegast::ClientBuilder;
use tarantool::cbus;
use tarantool::fiber::Fiber;
pub const CBUS_ENDPOINT: &str = "tests_endpoint";
// initialize cbus first
pub fn init_cbus() {
let mut fiber = Fiber::new("cbus_endpoint_f", &mut |_: Box<()>| {
let cbus_endpoint = cbus::Endpoint::new(CBUS_ENDPOINT).unwrap();
cbus_endpoint.cbus_loop();
0
});
fiber.start(());
}
fn main() {
init_cbus();
let client = picoslon::ClientBuilder::new()
.build("host=localhost user=user password=password dbname=db", picoslon::postegress::NoTls, CBUS_ENDPOINT)
.unwrap();
}
If you want, you can manually define a tokio runtime (instead of default)
for interaction with underline tokio-postgres
library.
Now you have the opportunity to query some data:
let count = client.query_one("SELECT count(*) FROM some_table", &[]).unwrap();
println!("count is {}", count.get::<_, i64>(0));
To familiarize with request APIs see the postgres docs.
We use tarantool-test. Run tests:
docker-compose up -d
cargo build
tarantool-test -p ./target/debug/libtests.so