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
impl IgniteClient
Sourcepub fn new(config: IgniteClientConfig) -> Self
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.
Sourcepub async fn query(
&self,
sql: &str,
params: Vec<IgniteValue>,
) -> Result<QueryResult>
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());
}Sourcepub async fn query_stream(
&self,
sql: &str,
params: Vec<IgniteValue>,
) -> Result<QueryStream>
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.
Sourcepub async fn execute(
&self,
sql: &str,
params: Vec<IgniteValue>,
) -> Result<UpdateResult>
pub async fn execute( &self, sql: &str, params: Vec<IgniteValue>, ) -> Result<UpdateResult>
Execute a DML statement (INSERT/UPDATE/DELETE).
Sourcepub async fn begin_transaction(&self) -> Result<Transaction>
pub async fn begin_transaction(&self) -> Result<Transaction>
Begin a new transaction with Pessimistic / ReadCommitted isolation (sensible default).
Sourcepub async fn begin_transaction_with(
&self,
concurrency: TxConcurrency,
isolation: TxIsolation,
timeout_ms: i64,
) -> Result<Transaction>
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.
Sourcepub async fn with_transaction<F, Fut, T>(&self, f: F) -> Result<T>
pub async fn with_transaction<F, Fut, T>(&self, f: F) -> Result<T>
Convenience: run a closure in a transaction, committing on success. The closure receives the transaction and must return it alongside its result.
Sourcepub fn pool_status(&self) -> Status
pub fn pool_status(&self) -> Status
Pool status for observability.
Sourcepub fn cache(&self, name: &str) -> IgniteCache
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).
Sourcepub async fn get_or_create_cache(&self, name: &str) -> Result<IgniteCache>
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.
Sourcepub async fn get_or_create_transactional_cache(
&self,
name: &str,
) -> Result<IgniteCache>
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.
Sourcepub async fn destroy_cache(&self, name: &str) -> Result<()>
pub async fn destroy_cache(&self, name: &str) -> Result<()>
Destroy the named cache. All data is permanently lost.
Sourcepub async fn cache_names(&self) -> Result<Vec<String>>
pub async fn cache_names(&self) -> Result<Vec<String>>
Return the names of all caches currently defined on the server.
Sourcepub async fn binary_type(&self, type_id: i32) -> Result<Option<Arc<BinaryType>>>
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).
Sourcepub async fn register_binary_type(&self, t: &BinaryType) -> Result<()>
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
impl Clone for IgniteClient
Source§fn clone(&self) -> IgniteClient
fn clone(&self) -> IgniteClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more