pub struct Stream { /* private fields */ }
Expand description
Abstraction, providing sequential processing of requests.
With streams there is a guarantee that the server instance will not handle the next request in a stream until it has completed the previous one (docs).
§Example
use tarantool_rs::{Connection, Executor, ExecutorExt};
let connection = Connection::builder().build("localhost:3301").await.unwrap();
// This will print 'fast' and then 'slow'
let eval_slow_fut = connection
.eval("fiber = require('fiber'); fiber.sleep(0.5); return ...;", ("slow", ))
.inspect(|res| println!("{:?}", res));
let eval_fast_fut = connection
.eval("return ...;", ("fast", ))
.inspect(|res| println!("{:?}", res));
let _ = tokio::join!(eval_slow_fut, eval_fast_fut);
// This will print 'slow' and then 'fast', since slow request was created first and have smaller sync
let stream = connection.stream();
let eval_slow_fut = stream
.eval("fiber = require('fiber'); fiber.sleep(0.5); return ...;", ("slow", ))
.inspect(|res| println!("{:?}", res));
let eval_fast_fut = stream
.eval("return ...;", ("fast", ))
.inspect(|res| println!("{:?}", res));
let _ = tokio::join!(eval_slow_fut, eval_fast_fut);
Trait Implementations§
Source§impl Executor for Stream
impl Executor for Stream
Source§fn send_encoded_request<'life0, 'async_trait>(
&'life0 self,
request: EncodedRequest,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_encoded_request<'life0, 'async_trait>(
&'life0 self,
request: EncodedRequest,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send encoded request.
Source§fn transaction_builder(&self) -> TransactionBuilder
fn transaction_builder(&self) -> TransactionBuilder
Prepare
TransactionBuilder
, which can be used to override parameters and create
Transaction
. Read moreSource§fn transaction<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn transaction<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create
Transaction
with parameters from builder. Read morefn get_cached_sql_statement_id<'life0, 'life1, 'async_trait>(
&'life0 self,
statement: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for Stream
impl !RefUnwindSafe for Stream
impl Send for Stream
impl Sync for Stream
impl Unpin for Stream
impl !UnwindSafe for Stream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<E> ExecutorExt for E
impl<E> ExecutorExt for E
Source§fn send_request<R>(
&self,
body: R,
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + '_>>where
R: Request,
fn send_request<R>(
&self,
body: R,
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + '_>>where
R: Request,
Send request, receiving raw response body. Read more
Source§fn ping<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn ping<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Ping tarantool instance.
Source§fn eval<'life0, 'async_trait, A, I>(
&'life0 self,
expr: I,
args: A,
) -> Pin<Box<dyn Future<Output = Result<CallResponse>> + Send + 'async_trait>>
fn eval<'life0, 'async_trait, A, I>( &'life0 self, expr: I, args: A, ) -> Pin<Box<dyn Future<Output = Result<CallResponse>> + Send + 'async_trait>>
Evaluate Lua expression. Read more
Source§fn call<'life0, 'async_trait, A, I>(
&'life0 self,
function_name: I,
args: A,
) -> Pin<Box<dyn Future<Output = Result<CallResponse>> + Send + 'async_trait>>
fn call<'life0, 'async_trait, A, I>( &'life0 self, function_name: I, args: A, ) -> Pin<Box<dyn Future<Output = Result<CallResponse>> + Send + 'async_trait>>
Remotely call function in Tarantool. Read more
Source§fn select<'life0, 'async_trait, T, A>(
&'life0 self,
space_id: u32,
index_id: u32,
limit: Option<u32>,
offset: Option<u32>,
iterator: Option<IteratorType>,
keys: A,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
T: DeserializeOwned + 'async_trait,
A: Tuple + Send + 'async_trait,
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn select<'life0, 'async_trait, T, A>(
&'life0 self,
space_id: u32,
index_id: u32,
limit: Option<u32>,
offset: Option<u32>,
iterator: Option<IteratorType>,
keys: A,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
T: DeserializeOwned + 'async_trait,
A: Tuple + Send + 'async_trait,
Self: Sync + 'async_trait,
'life0: 'async_trait,
Select tuples from space.
Source§fn insert<'life0, 'async_trait, T>(
&'life0 self,
space_id: u32,
tuple: T,
) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
fn insert<'life0, 'async_trait, T>( &'life0 self, space_id: u32, tuple: T, ) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
Insert tuple.
Source§fn update<'life0, 'async_trait, K, O>(
&'life0 self,
space_id: u32,
index_id: u32,
keys: K,
ops: O,
) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
fn update<'life0, 'async_trait, K, O>( &'life0 self, space_id: u32, index_id: u32, keys: K, ops: O, ) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
Update tuple.
Source§fn upsert<'life0, 'async_trait, T, O>(
&'life0 self,
space_id: u32,
tuple: T,
ops: O,
) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
fn upsert<'life0, 'async_trait, T, O>( &'life0 self, space_id: u32, tuple: T, ops: O, ) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
Update or insert tuple.
Source§fn replace<'life0, 'async_trait, T>(
&'life0 self,
space_id: u32,
tuple: T,
) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
fn replace<'life0, 'async_trait, T>( &'life0 self, space_id: u32, tuple: T, ) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
Insert a tuple into a space. If a tuple with the same primary key already exists,
replaces the existing tuple with a new one.
Source§fn delete<'life0, 'async_trait, T>(
&'life0 self,
space_id: u32,
index_id: u32,
keys: T,
) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
fn delete<'life0, 'async_trait, T>( &'life0 self, space_id: u32, index_id: u32, keys: T, ) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
Delete a tuple identified by the primary key.
Source§fn execute_sql<'life0, 'async_trait, T, I>(
&'life0 self,
query: I,
binds: T,
) -> Pin<Box<dyn Future<Output = Result<SqlResponse>> + Send + 'async_trait>>
fn execute_sql<'life0, 'async_trait, T, I>( &'life0 self, query: I, binds: T, ) -> Pin<Box<dyn Future<Output = Result<SqlResponse>> + Send + 'async_trait>>
Perform SQL query.
Source§fn prepare_sql<'life0, 'async_trait, I>(
&'life0 self,
query: I,
) -> Pin<Box<dyn Future<Output = Result<PreparedSqlStatement<&Self>>> + Send + 'async_trait>>
fn prepare_sql<'life0, 'async_trait, I>( &'life0 self, query: I, ) -> Pin<Box<dyn Future<Output = Result<PreparedSqlStatement<&Self>>> + Send + 'async_trait>>
Prepare SQL statement.
Source§fn space<'life0, 'async_trait, K>(
&'life0 self,
key: K,
) -> Pin<Box<dyn Future<Output = Result<Option<Space<&Self>>>> + Send + 'async_trait>>
fn space<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<Space<&Self>>>> + Send + 'async_trait>>
Find and load space by key. Read more