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 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 { columns, rows }
payload. 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.