Expand description
Query cancellation abstraction.
Hyper supports two transport flavors — the PostgreSQL wire protocol over
TCP / domain sockets / named pipes, and gRPC over HTTP/2 (used by
Salesforce Data 360). Each transport has its own idiomatic way to signal
“cancel the query currently running on this connection”:
| Transport | Cancel mechanism |
|---|---|
| PG wire | Open a separate connection to the same endpoint and send a pre-auth CancelRequest packet (process id + secret key). The server recognizes it and signals the in-flight query on the original connection to abort. |
| gRPC | Send a cancel_query(query_id) RPC over the same HTTP/2 channel (HTTP/2 natively multiplexes streams). |
Both boil down to a “fire-and-forget best-effort cancel” from the
caller’s point of view, so we expose them through the Cancellable
trait. Consumers (e.g. super::client::QueryStream’s Drop impl)
take a &dyn Cancellable and don’t care which transport is underneath.
Cancellation is inherently racy: the server may have already emitted
the last DataRow before the cancel lands, the query may complete
normally before the cancel is processed, or the network may drop the
cancel packet entirely. All implementations therefore treat cancel as
best-effort: errors are logged via tracing::warn! and then swallowed,
because callers are typically in destructor or error-cleanup paths
where propagating an error is inappropriate.
Traits§
- Cancellable
- Anything that can signal the server to abort the query currently running on an associated connection.