pub struct RXQLiteClient {
    pub leader: Arc<Mutex<(NodeId, String)>>,
    pub node: Arc<Mutex<(NodeId, String)>>,
    pub inner: Client,
    pub use_tls: bool,
    pub accept_invalid_certificates: bool,
    pub notification_stream: Option<NetStream>,
}

Fields§

§leader: Arc<Mutex<(NodeId, String)>>

The leader node to send request to.

All traffic should be sent to the leader in a cluster.

§node: Arc<Mutex<(NodeId, String)>>

The original node to send request to.

Mainly used to get node metrics.

§inner: Client§use_tls: bool§accept_invalid_certificates: bool§notification_stream: Option<NetStream>

Implementations§

source§

impl RXQLiteClient

source

pub fn with_options(options: &ConnectOptions) -> Self

source

pub fn new(node_id: NodeId, node_addr: &str) -> Self

Create a client with a leader node id and a node manager to get node address by node id.

source

pub async fn sql( &self, req: &Request ) -> Result<ClientWriteResponse, RPCError<ClientWriteError>>

Submit a write request to the raft cluster.

The request will be processed by raft protocol: it will be replicated to a quorum and then will be applied to state machine.

The result of applying the request will be returned.

source

pub async fn sql_with_retries_and_delay( &self, req: &Request, retries: usize, delay_between_retries: Duration ) -> Result<ClientWriteResponse, RPCError<ClientWriteError>>

source

pub async fn consistent_sql( &self, req: &Request ) -> Result<ClientWriteResponse, RPCError<ClientWriteError>>

source

pub async fn execute( &self, query: &str, arguments: Vec<Value> ) -> Result<Rows, RXQLiteError>

source

pub async fn fetch_all( &self, query: &str, arguments: Vec<Value> ) -> Result<Rows, RXQLiteError>

source

pub async fn fetch_one( &self, query: &str, arguments: Vec<Value> ) -> Result<Row, RXQLiteError>

source

pub async fn fetch_optional( &self, query: &str, arguments: Vec<Value> ) -> Result<Option<Row>, RXQLiteError>

source

pub async fn add_learner( &self, req: (NodeId, String, String) ) -> Result<ClientWriteResponse, RPCError<ClientWriteError>>

Add a node as learner.

The node to add has to exist, i.e., being added with write(ExampleRequest::AddNode{})

source

pub async fn change_membership( &self, req: &BTreeSet<NodeId> ) -> Result<ClientWriteResponse, RPCError<ClientWriteError>>

Change membership to the specified set of nodes.

All nodes in req have to be already added as learner with [add_learner], or an error LearnerNotFound will be returned.

source

pub async fn metrics(&self) -> Result<RaftMetrics, RPCError<Infallible>>

Get the metrics about the cluster.

Metrics contains various information about the cluster, such as current leader, membership config, replication status etc. See RaftMetrics.

source

pub async fn node_metrics(&self) -> Result<RaftMetrics, RPCError<Infallible>>

Get the metrics about the cluster from the original node.

Metrics contains various information about the cluster, such as current leader, membership config, replication status etc. See RaftMetrics.

source§

impl RXQLiteClient

source

pub async fn stop_listening_for_notifications(&mut self) -> Result<()>

source

pub async fn start_listening_for_notifications( &mut self, notifications_addr: &str ) -> Result<()>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more