pub struct SnowflakeSession { /* private fields */ }Expand description
A live, authenticated Snowflake session.
Holds the session and master tokens behind a mutex so a query (reading the
session token) and a heartbeat/renew can interleave. query runs SQL;
renew swaps in a fresh session token via the master token; heartbeat
keeps the master token alive so renewal can continue indefinitely.
Implementations§
Source§impl SnowflakeSession
impl SnowflakeSession
Sourcepub fn abort_handle(&self) -> AbortHandle
pub fn abort_handle(&self) -> AbortHandle
A cloneable AbortHandle for this session’s in-flight statement.
The returned handle shares the session’s in-flight slot, so it can cancel whatever statement is running even after the session is checked out of a pool (moved out of the pool’s slot).
Sourcepub fn session_expiring_within(&self, within: TimeDelta) -> bool
pub fn session_expiring_within(&self, within: TimeDelta) -> bool
Whether the session token expires within within from now.
Sourcepub fn master_expires_at(&self) -> DateTime<Utc>
pub fn master_expires_at(&self) -> DateTime<Utc>
When the master token currently expires (renewal must happen before this,
kept alive by heartbeat).
Sourcepub async fn query(&self, sql: &str) -> Result<Vec<Row>>
pub async fn query(&self, sql: &str) -> Result<Vec<Row>>
Runs SQL and returns the result rows.
§Errors
Error::SessionExpired when the session token is no longer valid (renew
or re-authenticate), or a transport/server/protocol error.
Sourcepub async fn query_multi(&self, sql: &str) -> Result<Vec<Vec<Row>>>
pub async fn query_multi(&self, sql: &str) -> Result<Vec<Vec<Row>>>
Runs SQL that may contain multiple ;-separated statements, returning
one row set per statement (in submission order).
A single-statement submission takes the same path as query
and yields a one-element vector. When the SQL parses to more than one
statement it is submitted with MULTI_STATEMENT_COUNT = 0 (“any count”):
the server then returns a comma-separated list of child resultIds in
place of inline rows, and each child result is fetched from the
/queries/{id}/result endpoint.
§Errors
As query.
Sourcepub async fn renew(&self) -> Result<()>
pub async fn renew(&self) -> Result<()>
Renews the session token using the master token, extending the session.
§Errors
Error::SessionExpired when the master token has itself expired (a full
re-authentication is then required), or a transport/server error.