Struct tarantool_rs::Stream
source · 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 !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<E> ExecutorExt for Ewhere
E: Executor + ?Sized,
impl<E> ExecutorExt for Ewhere E: Executor + ?Sized,
source§fn send_request<R>(
&self,
body: R
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + '_, Global>>where
R: Request,
fn send_request<R>( &self, body: R ) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + '_, Global>>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>>where
A: Tuple + Send + 'async_trait,
I: AsRef<str> + Send + Sync + 'async_trait,
Self: Sync + 'async_trait,
'life0: '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>>where A: Tuple + Send + 'async_trait, I: AsRef<str> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: '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>>where
A: Tuple + Send + 'async_trait,
I: AsRef<str> + Send + Sync + 'async_trait,
Self: Sync + 'async_trait,
'life0: '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>>where A: Tuple + Send + 'async_trait, I: AsRef<str> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: '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>>where
T: Tuple + Send + 'async_trait,
Self: Sync + 'async_trait,
'life0: '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>>where T: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: '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>>where
K: Tuple + Send + 'async_trait,
O: Tuple + Send + 'async_trait,
Self: Sync + 'async_trait,
'life0: '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>>where K: Tuple + Send + 'async_trait, O: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: '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>>where
T: Tuple + Send + 'async_trait,
O: Tuple + Send + 'async_trait,
Self: Sync + 'async_trait,
'life0: '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>>where T: Tuple + Send + 'async_trait, O: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: '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>>where
T: Tuple + Send + 'async_trait,
Self: Sync + 'async_trait,
'life0: '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>>where T: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: '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>>where
T: Tuple + Send + 'async_trait,
Self: Sync + 'async_trait,
'life0: '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>>where T: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: '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>>where
T: Tuple + Send + 'async_trait,
I: AsRef<str> + Send + Sync + 'async_trait,
Self: Sync + 'async_trait,
'life0: '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>>where T: Tuple + Send + 'async_trait, I: AsRef<str> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: '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>>where
I: AsRef<str> + Send + Sync + 'async_trait,
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn prepare_sql<'life0, 'async_trait, I>( &'life0 self, query: I ) -> Pin<Box<dyn Future<Output = Result<PreparedSqlStatement<&Self>>> + Send + 'async_trait>>where I: AsRef<str> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: '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>>where
Self: Sized + Send + Sync + 'async_trait,
K: Into<SchemaEntityKey> + Send + 'async_trait,
'life0: 'async_trait,
fn space<'life0, 'async_trait, K>( &'life0 self, key: K ) -> Pin<Box<dyn Future<Output = Result<Option<Space<&Self>>>> + Send + 'async_trait>>where Self: Sized + Send + Sync + 'async_trait, K: Into<SchemaEntityKey> + Send + 'async_trait, 'life0: 'async_trait,
Find and load space by key. Read more