Struct google_cloud_spanner::transaction::QueryOptions
source · pub struct QueryOptions {
pub mode: QueryMode,
pub optimizer_options: Option<ExecuteQueryOptions>,
pub call_options: CallOptions,
pub enable_resume: bool,
}Fields§
§mode: QueryMode§optimizer_options: Option<ExecuteQueryOptions>§call_options: CallOptions§enable_resume: boolIf cancel safe is required, such as when tokio::select is used, set to false.
use time::{Duration, OffsetDateTime};
use google_cloud_spanner::reader::AsyncIterator;
use google_cloud_spanner::client::Client;
use google_cloud_spanner::key::Key;
use google_cloud_spanner::statement::Statement;
use google_cloud_spanner::transaction::QueryOptions;
async fn query(client: Client) {
let mut tx = client.single().await.unwrap();
let option = QueryOptions {
enable_resume: false,
..Default::default()
};
let mut stmt = Statement::new("SELECT ChangeRecord FROM READ_UserItemChangeStream (
start_timestamp => @now,
end_timestamp => NULL,
partition_token => {},
heartbeat_milliseconds => 10000
)");
stmt.add_param("now", &OffsetDateTime::now_utc());
let mut rows = tx.query_with_option(stmt, option).await.unwrap();
let mut tick = tokio::time::interval(tokio::time::Duration::from_millis(100));
loop {
tokio::select! {
_ = tick.tick() => {
// run task
},
maybe = rows.next() => {
let row = maybe.unwrap().unwrap();
}
}
}
}Trait Implementations§
source§impl Clone for QueryOptions
impl Clone for QueryOptions
source§fn clone(&self) -> QueryOptions
fn clone(&self) -> QueryOptions
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl RefUnwindSafe for QueryOptions
impl Send for QueryOptions
impl Sync for QueryOptions
impl Unpin for QueryOptions
impl UnwindSafe for QueryOptions
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request