Struct rxqlite_client::RXQLiteClient
source · 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
impl RXQLiteClient
pub fn with_options(options: &ConnectOptions) -> Self
sourcepub fn new(node_id: NodeId, node_addr: &str) -> Self
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.
sourcepub async fn sql(
&self,
req: &Request
) -> Result<ClientWriteResponse, RPCError<ClientWriteError>>
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.
pub async fn sql_with_retries_and_delay( &self, req: &Request, retries: usize, delay_between_retries: Duration ) -> Result<ClientWriteResponse, RPCError<ClientWriteError>>
pub async fn consistent_sql( &self, req: &Request ) -> Result<ClientWriteResponse, RPCError<ClientWriteError>>
pub async fn execute( &self, query: &str, arguments: Vec<Value> ) -> Result<Rows, RXQLiteError>
pub async fn fetch_all( &self, query: &str, arguments: Vec<Value> ) -> Result<Rows, RXQLiteError>
pub async fn fetch_one( &self, query: &str, arguments: Vec<Value> ) -> Result<Row, RXQLiteError>
pub async fn fetch_optional( &self, query: &str, arguments: Vec<Value> ) -> Result<Option<Row>, RXQLiteError>
sourcepub async fn add_learner(
&self,
req: (NodeId, String, String)
) -> Result<ClientWriteResponse, RPCError<ClientWriteError>>
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{})
sourcepub async fn change_membership(
&self,
req: &BTreeSet<NodeId>
) -> Result<ClientWriteResponse, RPCError<ClientWriteError>>
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.
sourcepub async fn metrics(&self) -> Result<RaftMetrics, RPCError<Infallible>>
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.
sourcepub async fn node_metrics(&self) -> Result<RaftMetrics, RPCError<Infallible>>
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.