pub struct Client { /* private fields */ }Expand description
API to tarantool.
Create client by call build() on ClientConfig.
§Examples
let client = ClientConfig::new(addr, “rust”, “rust”).set_timeout_time_ms(1000).set_reconnect_time_ms(10000).build();
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(config: ClientConfig) -> Client
pub fn new(config: ClientConfig) -> Client
manually create client by consume Client Config
Sourcepub fn prepare_sql<T>(&self, sql: T) -> PreparedSql
pub fn prepare_sql<T>(&self, sql: T) -> PreparedSql
prepare sql call
§Examples
rust code
let response : TarantoolSqlResponse<(u32, String)> = client
.prepare_sql("select * from TABLE1 where COLUMN1=?")
.bind(&1)?
.execute().await?;
let rows = response.decode_result_set()?;Sourcepub fn prepare_fn_call<T>(&self, function_name: T) -> PreparedFunctionCall
pub fn prepare_fn_call<T>(&self, function_name: T) -> PreparedFunctionCall
prepare call to stored procedure
§Examples
rust code
let response = client
.prepare_fn_call("test")
.bind(&("aa", "aa"))?
.bind(&1)?
.execute().await?;
let s: (Vec<String>, u64) = response.decode_pair()?;Sourcepub fn get_status(&self) -> ClientStatus
pub fn get_status(&self) -> ClientStatus
return client status
Sourcepub fn subscribe_to_notify_stream(&self) -> UnboundedReceiver<ClientStatus>
pub fn subscribe_to_notify_stream(&self) -> UnboundedReceiver<ClientStatus>
return notify stream with connection statuses
Sourcepub async fn send_command(
&self,
req: CommandPacket,
) -> Result<TarantoolResponse>
pub async fn send_command( &self, req: CommandPacket, ) -> Result<TarantoolResponse>
send any command you manually create, this method is low level and not intended to be used
Sourcepub async fn call_fn<T>(
&self,
function: &str,
params: &T,
) -> Result<TarantoolResponse>where
T: Serialize,
pub async fn call_fn<T>(
&self,
function: &str,
params: &T,
) -> Result<TarantoolResponse>where
T: Serialize,
call tarantool stored procedure
params mast be serializable to MsgPack tuple by Serde - rust tuple or vector or struct (by default structs serialized as tuple)
order of fields in serializes tuple is order of parameters of procedure
§Examples
lua function on tarantool
function test(a,b)
return a,b,11
endrust code
let response = client.call_fn("test", &(("aa", "aa"), 1)).await?;
let s: (Vec<String>, Vec<u64>) = response.decode_pair()?;
println!("resp value={:?}", s);
assert_eq!((vec!["aa".to_string(), "aa".to_string()], vec![1]), s);Sourcepub async fn call_fn1<T1>(
&self,
function: &str,
param1: &T1,
) -> Result<TarantoolResponse>where
T1: Serialize,
pub async fn call_fn1<T1>(
&self,
function: &str,
param1: &T1,
) -> Result<TarantoolResponse>where
T1: Serialize,
call tarantool stored procedure with one parameter
Sourcepub async fn call_fn2<T1, T2>(
&self,
function: &str,
param1: &T1,
param2: &T2,
) -> Result<TarantoolResponse>
pub async fn call_fn2<T1, T2>( &self, function: &str, param1: &T1, param2: &T2, ) -> Result<TarantoolResponse>
call tarantool stored procedure with two parameters
§Examples
let response = client.call_fn2("test", &("param11", "param12") , &2).await?;
let s: (Vec<String>, Vec<u64>) = response.decode_pair()?;
println!("resp value={:?}", s);
assert_eq!((vec!["aa".to_string(), "aa".to_string()], vec![1]), s);Sourcepub async fn call_fn3<T1, T2, T3>(
&self,
function: &str,
param1: &T1,
param2: &T2,
param3: &T3,
) -> Result<TarantoolResponse>
pub async fn call_fn3<T1, T2, T3>( &self, function: &str, param1: &T1, param2: &T2, param3: &T3, ) -> Result<TarantoolResponse>
call tarantool stored procedure with three parameters
Sourcepub async fn call_fn4<T1, T2, T3, T4>(
&self,
function: &str,
param1: &T1,
param2: &T2,
param3: &T3,
param4: &T4,
) -> Result<TarantoolResponse>
pub async fn call_fn4<T1, T2, T3, T4>( &self, function: &str, param1: &T1, param2: &T2, param3: &T3, param4: &T4, ) -> Result<TarantoolResponse>
call tarantool stored procedure with four parameters
Sourcepub async fn call_fn5<T1, T2, T3, T4, T5>(
&self,
function: &str,
param1: &T1,
param2: &T2,
param3: &T3,
param4: &T4,
param5: &T5,
) -> Result<TarantoolResponse>
pub async fn call_fn5<T1, T2, T3, T4, T5>( &self, function: &str, param1: &T1, param2: &T2, param3: &T3, param4: &T4, param5: &T5, ) -> Result<TarantoolResponse>
call tarantool stored procedure with five parameters
Sourcepub async fn select<T>(
&self,
space: i32,
index: i32,
key: &T,
offset: i32,
limit: i32,
iterator: IteratorType,
) -> Result<TarantoolResponse>where
T: Serialize,
pub async fn select<T>(
&self,
space: i32,
index: i32,
key: &T,
offset: i32,
limit: i32,
iterator: IteratorType,
) -> Result<TarantoolResponse>where
T: Serialize,
call “select” from tarantool
- space - i32 space id
- index - i32 index id
- key - key part used for select, may be sequence (vec or tuple)
- offset - i32 select offset
- limit - i32 limit of rows
- iterator - type of iterator
Sourcepub async fn insert<T>(
&self,
space: i32,
tuple: &T,
) -> Result<TarantoolResponse>where
T: Serialize,
pub async fn insert<T>(
&self,
space: i32,
tuple: &T,
) -> Result<TarantoolResponse>where
T: Serialize,
insert tuple to space
- space - space id
- tuple - sequence of fields(can be vec or rust tuple)
Sourcepub async fn replace<T>(
&self,
space: i32,
tuple: &T,
) -> Result<TarantoolResponse>where
T: Serialize,
pub async fn replace<T>(
&self,
space: i32,
tuple: &T,
) -> Result<TarantoolResponse>where
T: Serialize,
replace tuple in space by primary key
- space - space id
- tuple - sequence of fields(can be vec or rust tuple)
§Examples
let tuple_replace= (3,"test_insert","replace");
client.replace(SPACE_ID, &tuple_replace).await?;Sourcepub async fn replace_raw(
&self,
space: i32,
tuple_raw: Vec<u8>,
) -> Result<TarantoolResponse>
pub async fn replace_raw( &self, space: i32, tuple_raw: Vec<u8>, ) -> Result<TarantoolResponse>
replace tuple in space by primary key - raw method if you have already serialized msgpack
- space - space id
- tuple - sequence of fields stored as msgpack
§Examples
let tuple_replace= (3,"test_insert","replace");
let raw_buf = serialize_to_vec_u8(&tuple_replace).unwrap();
client.replace_raw(SPACE_ID, raw_buf).await?;Sourcepub async fn update<T, T2>(
&self,
space: i32,
key: &T2,
args: &T,
) -> Result<TarantoolResponse>
pub async fn update<T, T2>( &self, space: i32, key: &T2, args: &T, ) -> Result<TarantoolResponse>
update row in tarantool
- space - space id
- key - sequence of fields(rust tuple or vec)
- args - sequence of update operations, for example ((‘=’,2,“test_update”),)
§Examples
let tuple= (3,"test_insert");
let update_op= (('=',2,"test_update"),);
client.update(SPACE_ID, &tuple, &update_op).await?;Sourcepub async fn upsert<T, T2, T3>(
&self,
space: i32,
key: &T2,
def: &T3,
args: &T,
) -> Result<TarantoolResponse>
pub async fn upsert<T, T2, T3>( &self, space: i32, key: &T2, def: &T3, args: &T, ) -> Result<TarantoolResponse>
upsert row in tuple
§Examples
let key= (4,"test_upsert");
let update_op= (('=',2,"test_update_upsert"),);
client.upsert(SPACE_ID,&key, &key,&update_op).await?;Sourcepub async fn delete<T>(&self, space: i32, key: &T) -> Result<TarantoolResponse>where
T: Serialize,
pub async fn delete<T>(&self, space: i32, key: &T) -> Result<TarantoolResponse>where
T: Serialize,
Sourcepub async fn eval<T, T1>(
&self,
expression: T1,
args: &T,
) -> Result<TarantoolResponse>
pub async fn eval<T, T1>( &self, expression: T1, args: &T, ) -> Result<TarantoolResponse>
Sourcepub async fn exec_sql<T, T1>(
&self,
sql: T1,
args: &T,
) -> Result<TarantoolResponse>
pub async fn exec_sql<T, T1>( &self, sql: T1, args: &T, ) -> Result<TarantoolResponse>
eval sql expression in tarantool
§Examples
client.exec_sql("select * from TABLE1 where COLUMN1=?".to_string(), &(1,)).await?;