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