[−][src]Struct dgraph_tonic::Client
Async client for dGraph DB.
Methods
impl Client
[src]
pub async fn new<S: TryInto<Uri>>(endpoints: Vec<S>) -> Result<Self, Error>
[src]
Create new dGraph client for interacting v DB and try to connect to given endpoints.
The client can be backed by multiple endpoints (to the same server, or multiple servers in a cluster).
Arguments
endpoints
- Vector of possible endpoints
Errors
- connection to DB fails
- endpoints vector is empty
- item in vector cannot by converted into Uri
Example
use dgraph_tonic::Client; #[tokio::main] async fn main() { let client = Client::new(vec!["http://127.0.0.1:19080"]).await.expect("Connected to dGraph"); }
pub async fn new_with_tls_client_auth<S: TryInto<Uri>>(
endpoints: Vec<S>,
server_root_ca_cert: impl AsRef<Path>,
client_cert: impl AsRef<Path>,
client_key: impl AsRef<Path>
) -> Result<Self, Error>
[src]
endpoints: Vec<S>,
server_root_ca_cert: impl AsRef<Path>,
client_cert: impl AsRef<Path>,
client_key: impl AsRef<Path>
) -> Result<Self, Error>
Create new dGraph client authorized with SSL cert for interacting v DB and try to connect to given endpoints.
The client can be backed by multiple endpoints (to the same server, or multiple servers in a cluster).
Arguments
endpoints
- Vector of possible endpointsserver_root_ca_cert
- path to server CA certificateclient_cert
- path to client certificateclient_key
- path to client private key
Errors
- connection to DB fails
- endpoints vector is empty
- item in vector cannot by converted into Uri
pub fn new_txn(&self) -> Txn
[src]
Return transaction in default state, which can be specialized into ReadOnly or Mutated
pub fn new_read_only_txn(&self) -> ReadOnlyTxn
[src]
Create new transaction which can only do queries.
Read-only transactions are useful to increase read speed because they can circumvent the usual consensus protocol.
pub fn new_best_effort_txn(&self) -> BestEffortTxn
[src]
Create new transaction which can only do queries in best effort mode.
Read-only queries can optionally be set as best-effort. Using this flag will ask the Dgraph Alpha to try to get timestamps from memory on a best-effort basis to reduce the number of outbound requests to Zero. This may yield improved latencies in read-bound workloads where linearizable reads are not strictly needed.
pub fn new_mutated_txn(&self) -> MutatedTxn
[src]
Create new transaction which can do mutate, commit and discard operations
pub async fn alter<'_>(&'_ self, op: Operation) -> Result<Payload, Status>
[src]
The /alter endpoint is used to create or change the schema.
Arguments
op
: Alter operation
Errors
- gRPC error
- DB reject alter command
Example
Install a schema into dgraph. A name
predicate is string type and has exact index.
use dgraph_tonic::{Client, Operation}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let client = Client::new(vec!["http://127.0.0.1:19080"]).await.expect("Connected to dGraph"); let op = Operation { schema: "name: string @index(exact) .".into(), ..Default::default() }; client.alter(op).await.expect("Schema is not updated"); Ok(()) }
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoRequest<T> for T
[src]
fn into_request(self) -> Request<T>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,