Skip to main content

IgniteClient

Struct IgniteClient 

Source
pub struct IgniteClient { /* private fields */ }
Expand description

The main Ignite client. Wraps a per-node connection registry with optional partition-aware routing; cheap to clone.

Implementations§

Source§

impl IgniteClient

Source

pub fn new(config: IgniteClientConfig) -> Self

Create a new client. Opens one pool per configured node address (no connections are made yet). Partition awareness defaults to on when ≥ 2 nodes are configured, unless explicitly overridden in the config.

Source

pub async fn query( &self, sql: &str, params: Vec<IgniteValue>, ) -> Result<QueryResult>

Execute a SELECT statement and return all rows.

§Example
let client = IgniteClient::new(IgniteClientConfig::new("localhost:10800"));
let result = client.query(
    "SELECT id, name FROM PUBLIC.users WHERE active = ?",
    vec![IgniteValue::Bool(true)],
).await.unwrap();
for row in &result.rows {
    println!("{:?}", row.values());
}
Source

pub async fn query_stream( &self, sql: &str, params: Vec<IgniteValue>, ) -> Result<QueryStream>

Execute a SELECT and return rows lazily as a QueryStream.

The first page is fetched immediately; subsequent pages are fetched on demand as the stream is polled. Use Self::query if you need all rows in a Vec up front.

The underlying connection is borrowed from the pool for the request and returned immediately; the stream holds a shared handle (clone) to the same TCP connection via the multiplexing design.

Source

pub async fn execute( &self, sql: &str, params: Vec<IgniteValue>, ) -> Result<UpdateResult>

Execute a DML statement (INSERT/UPDATE/DELETE).

Source

pub async fn begin_transaction(&self) -> Result<Transaction>

Begin a new transaction with Pessimistic / ReadCommitted isolation (sensible default).

Source

pub async fn begin_transaction_with( &self, concurrency: TxConcurrency, isolation: TxIsolation, timeout_ms: i64, ) -> Result<Transaction>

Begin a transaction with explicit concurrency/isolation settings.

Opens a dedicated TCP connection for the transaction’s lifetime so that the connection pool is not held hostage. The connection is closed when the Transaction is dropped.

Source

pub async fn with_transaction<F, Fut, T>(&self, f: F) -> Result<T>
where F: FnOnce(Transaction) -> Fut, Fut: Future<Output = Result<(Transaction, T)>>,

Convenience: run a closure in a transaction, committing on success. The closure receives the transaction and must return it alongside its result.

Source

pub fn pool_status(&self) -> Status

Pool status for observability.

Source

pub fn cache(&self, name: &str) -> IgniteCache

Return a IgniteCache handle for a cache that is assumed to already exist. This is a pure in-process operation (no network round-trip).

Source

pub async fn get_or_create_cache(&self, name: &str) -> Result<IgniteCache>

Create the named cache if it does not already exist, then return a handle to it. Equivalent to CACHE_GET_OR_CREATE_WITH_NAME.

Source

pub async fn get_or_create_transactional_cache( &self, name: &str, ) -> Result<IgniteCache>

Create the named cache with TRANSACTIONAL atomicity if it does not already exist, then return a handle to it. Uses CACHE_GET_OR_CREATE_WITH_CONFIGURATION (op 1054).

Required for caches that will be used inside KV transactions on Ignite ≥ 2.16, which forbids atomic-cache operations inside transactions.

Source

pub async fn destroy_cache(&self, name: &str) -> Result<()>

Destroy the named cache. All data is permanently lost.

Source

pub async fn cache_names(&self) -> Result<Vec<String>>

Return the names of all caches currently defined on the server.

Source

pub async fn binary_type(&self, type_id: i32) -> Result<Option<Arc<BinaryType>>>

Return the binary-type metadata for type_id, needed to decode compact-footer binary objects (schema field ids aren’t recoverable without it).

Checks a client-side cache first; on a miss, fetches it from the cluster via OP_BINARY_TYPE_GET and caches the result for subsequent calls. Returns Ok(None) if the server has no metadata registered for type_id (e.g. nothing of that type has ever been written).

Source

pub async fn register_binary_type(&self, t: &BinaryType) -> Result<()>

Register a binary type’s metadata with the cluster via OP_BINARY_TYPE_PUT, then cache an Arc clone under t.type_id.

This lets Rust register a brand-new type the Java side has never seen (or re-register an existing one — the server accepts idempotent PUTs of identical metadata). The success response body is empty; the connection’s request() already validates the header and returns an error for a failure response, so reaching this point means the PUT succeeded.

Trait Implementations§

Source§

impl Clone for IgniteClient

Source§

fn clone(&self) -> IgniteClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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