pub struct SnowflakeEngine { /* private fields */ }Expand description
The account-agnostic Snowflake query engine: lazy multiplexed auth, bounded per-identity session pools, and concurrent arbitrary-SQL execution.
A background keep-alive heartbeat for idle sessions is started by
start_heartbeat and stopped by
shutdown.
Implementations§
Source§impl SnowflakeEngine
impl SnowflakeEngine
Sourcepub fn new(config: SnowflakeEngineConfig) -> Self
pub fn new(config: SnowflakeEngineConfig) -> Self
Builds an engine. Cheap — no eager auth or I/O.
Sourcepub fn start_heartbeat(&self)
pub fn start_heartbeat(&self)
Starts the background keep-alive heartbeat loop (idempotent).
Every heartbeat_interval the loop heartbeats each pool’s idle sessions
— renewing a session token about to lapse — so the server-side
CLIENT_SESSION_KEEP_ALIVE actually extends the master token and an
idle pool survives past the token TTL without a new browser SSO (#1107).
Busy sessions are skipped; the query path keeps them alive inline.
No-op when the interval is zero (disabled) or when called outside a
tokio runtime. Stopped by shutdown.
Sourcepub fn sessions(&self) -> Vec<SessionInfo>
pub fn sessions(&self) -> Vec<SessionInfo>
A snapshot of every active pool.
Sourcepub fn pool_count(&self) -> usize
pub fn pool_count(&self) -> usize
The number of active pools ((account, user) identities).
Sourcepub fn disconnect(&self, account: &str, user: &str) -> bool
pub fn disconnect(&self, account: &str, user: &str) -> bool
Evicts the pool for (account, user). Returns whether one existed.
Sourcepub fn disconnect_by_id(&self, id: u64) -> bool
pub fn disconnect_by_id(&self, id: u64) -> bool
Evicts the pool with the given id. Returns whether one existed.
Sourcepub fn disconnect_all(&self) -> usize
pub fn disconnect_all(&self) -> usize
Evicts every pool. Returns how many were removed.
Sourcepub async fn cancel(
&self,
account: &str,
user: &str,
member: Option<u64>,
) -> usize
pub async fn cancel( &self, account: &str, user: &str, member: Option<u64>, ) -> usize
Cancels the running query on the (account, user) pool — one specific
member when member is Some, else every busy member. Returns how many
statements an abort was issued for. Does not create a pool, so an
unknown identity cancels nothing.
The pooled session frees itself promptly (its poll loop returns a cancelled error within one poll interval) rather than waiting out the query timeout.
Sourcepub async fn cancel_by_id(&self, id: u64, member: Option<u64>) -> usize
pub async fn cancel_by_id(&self, id: u64, member: Option<u64>) -> usize
Like cancel but selects the pool by its numeric id (as
shown by sessions).
Sourcepub async fn cancel_all(&self) -> usize
pub async fn cancel_all(&self) -> usize
Cancels every running query across all pools. Returns how many statements an abort was issued for.
Sourcepub async fn shutdown(&self)
pub async fn shutdown(&self)
Stops the keep-alive heartbeat, then drops every pool (and its sessions).
Sourcepub async fn query(&self, req: QueryRequest) -> Result<Value>
pub async fn query(&self, req: QueryRequest) -> Result<Value>
Runs arbitrary SQL against the (account, user) pool, authenticating a
session on first use, and returns a self-describing
{ statements: [ { columns, rows }, … ] } payload — one entry per
;-separated statement, so a single-statement query is a one-element
statements array (multi-statement scripts set MULTI_STATEMENT_COUNT).
Concurrent calls run on separate pooled sessions (up to the pool size).
§Errors
Returns an error if no account/user can be resolved, a context flag is not a valid identifier, authentication fails, or the query fails. On a session-expiry error that session is discarded and the next query re-authenticates.