pub struct QueryOptions {
pub mode: QueryMode,
pub optimizer_options: Option<QueryOptions>,
pub call_options: CallOptions,
pub enable_resume: bool,
}Fields§
§mode: QueryMode§optimizer_options: Option<QueryOptions>§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::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
Auto Trait Implementations§
impl Forget for QueryOptions
impl Freeze for QueryOptions
impl Move for QueryOptions
impl RefUnwindSafe for QueryOptions
impl Send for QueryOptions
impl Sync for QueryOptions
impl Unpin for QueryOptions
impl UnsafeUnpin 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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