1 个不稳定版本
0.1.5 | 2021年1月15日 |
---|
#1955 in 异步
51KB
1K SLoC
简单的Rust客户端,用于Tarantool
将Java连接器移植到Tarantool数据库
https://github.com/tarantool/tarantool-java
概述
使用tokio.io作为基础客户端框架
用法
示例
调用存储过程echo
运行tarantool
cd test-tarantool;tarantool init-tarantool.lua
Lua存储过程
function test(a,b)
return a,b,11
end
Rust客户端
println!("Connect to tarantool and call simple stored procedure!");
let mut rt = Runtime::new().unwrap();
let addr = "127.0.0.1:3301".parse().unwrap();
let client = ClientConfig::new(addr, "rust", "rust").build();
let response_future = client.call_fn2("test", &("param11", "param12") , &2)
.and_then(|response| {
let res : ((String,String), (u64,), (Option<u64>,)) = response.decode_trio()?;
Ok(res)
}) ;
match rt.block_on(response_future) {
Err(e) => println!("err={:?}", e),
Ok(res) => println!("stored procedure response ={:?}", res)
}
输出
Connect to tarantool and call simple stored procedure!
stored procedure response =(("param11", "param12"), (2,), (Some(11),))
在项目的示例部分,您还可以看到更复杂的示例
http服务器连接到tarantool
依赖项
~7–16MB
~197K SLoC