Skip to content

Tarantool connector for rust based on tokio

License

Notifications You must be signed in to change notification settings

measproem/alopecosa

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT licensed Version Code Coverage Downloads

Added support: UUID, DateTime, Decimal

I have forked for personal use not yet fully unit test but may benefit someone

Alopecosa

Alopecosa is a convenient async pure-rust Tarantool 1.6+ connector built on tokio (version 1).

By the way, alopecosa is the kind of tarantula that inhabits in Japan.

Documentation link

Crates.io link

Example

use std::{
  error::Error,
  time::Duration,
  sync::Arc,
};
use alopecosa::{
  Connection, Connector, IntoTuple,
  Call, Eval, Select, Iterator
};
use tokio::time::timeout;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
  let addr = "127.0.0.1:3301".parse()?;
  let conn: Arc<Connection> = Connector::new(addr)
    .connect().await?;

  let eval_resp: (u32, u32) = conn.eval(Eval {
    expr: "return 1, 2".into(),
    args: ().into_tuple(),
  }).await?;

  let select_resp: Vec<(u32, u32, u32)> = conn.select(Select {
    space_id: 512, index_id: 0,
    limit: 100, offset: 0,
    iterator: Iterator::Ge,
    keys: ( 1u64, ).into_tuple(),
  }).await?;

  let (resp_with_timeout,): (i32,) = timeout(
    Duration::from_secs(1),
    conn.call(Call {
      function: "echo".into(),
      args: ( 123, ).into_tuple(),
    })
  ).await??;

  Ok(())
}

Auth

let addr = "127.0.0.1:3301".parse()?;
let conn: Arc<Connection> = Connector::new(addr)
  .with_auth("user".into(), "password".into())
  .connect().await?;

Connection tuning

let addr = "127.0.0.1:3301".parse()?;
let conn: Arc<Connection> = Connector::new(addr)
  .with_connect_timeout(Duration::from_secs(10))
  .with_reconnect_interval(Duration::from_secs(1))
  .with_send_request_timeout(Duration::from_secs(10))
  .connect().await?;

About

Tarantool connector for rust based on tokio

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 99.3%
  • Lua 0.7%