pub struct CancelToken { /* private fields */ }Expand description
A token that can cancel a running query on a specific backend. Cloneable and Send, can be passed to another task or stored for timeout handling.
The backend secret is held internally and is not exposed through any
accessor; obtain a token from an AsyncConn / WireConn rather than
constructing one with raw fields.
Implementations§
Source§impl CancelToken
impl CancelToken
Sourcepub fn new(addr: String, pid: i32, secret: i32) -> CancelToken
pub fn new(addr: String, pid: i32, secret: i32) -> CancelToken
Construct a cancel token from raw parts. Intended for callers that
persisted the three values across processes; most users should get a
token from AsyncConn::cancel_token() instead.
Sourcepub async fn cancel(&self) -> Result<(), PgWireError>
pub async fn cancel(&self) -> Result<(), PgWireError>
Send a cancel request to PostgreSQL.
Opens a new TCP connection, sends the 16-byte CancelRequest, and closes. The server will attempt to cancel the current query on the target backend.
Note: cancellation is best-effort. The query may complete before the cancel arrives, or the server may not be able to cancel it immediately.
Times out after 5 seconds to prevent hanging if the server is unreachable.
Trait Implementations§
Source§impl Clone for CancelToken
impl Clone for CancelToken
Source§fn clone(&self) -> CancelToken
fn clone(&self) -> CancelToken
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more