dgraph_tonic/txn/
best_effort.rs1use std::collections::hash_map::RandomState;
2use std::collections::HashMap;
3use std::fmt::Debug;
4
5use crate::client::ILazyClient;
6use crate::txn::read_only::ReadOnly;
7use crate::txn::{IState, TxnReadOnlyType, TxnState, TxnVariant};
8use crate::Request;
9
10#[derive(Clone, Debug)]
14pub struct BestEffort<C: ILazyClient> {
15 read_only: ReadOnly<C>,
16}
17
18impl<C: ILazyClient> IState for BestEffort<C> {
19 fn query_request<S: ILazyClient>(
23 &self,
24 state: &TxnState<S>,
25 query: String,
26 vars: HashMap<String, String, RandomState>,
27 ) -> Request {
28 let mut request = self.read_only.query_request(state, query, vars);
29 request.best_effort = true;
30 request
31 }
32}
33
34pub type TxnBestEffortType<C> = TxnVariant<BestEffort<C>, C>;
38
39impl<C: ILazyClient> TxnReadOnlyType<C> {
40 pub fn best_effort(self) -> TxnBestEffortType<C> {
44 TxnVariant {
45 state: self.state,
46 extra: BestEffort {
47 read_only: self.extra,
48 },
49 }
50 }
51}