The clock's type. On native targets this is std::time::Instant itself
(web-time re-exports it). On wasm32-unknown-unknown, std's Instant::now
panics and the type has no other constructor, so a runtime there (a
Cloudflare Worker, a browser) could not implement [Runtime::now] at all
without web-time's performance.now()-backed one. SystemTime stays std's:
it can be built from UNIX_EPOCH plus a duration on any target.
11pub use web_time::Instant;
One POST to the System One endpoint the transport was built for.
Sends one request and returns the whole response. It does not retry, time out or interpret statuses: that is the client's.
The futures are not required to be Send: an adapter may be tied to
one thread, as the Postgres backend's is.
35pub trait Transport {
Waits until request may be sent, as a rate limit shared with
other senders decides. Called before every attempt, outside its
timeout and the retry budget, so a queue for the account's limit
is never mistaken for a slow server. The default sends at once.
44 fn send(&self, request: HttpRequest) -> impl Future<Output = Result<HttpResponse, TransportError>>;
The client gave up on an exchange (it timed out). The connection it ran on is suspect: the next send should not reuse it.
Time and randomness, so the policy can run on virtual time in tests.
Wall-clock time, for an HTTP-date Retry-After.
future, or None if duration passes first (dropping it).
58 fn timeout<F: Future>(&self, duration: Duration, future: F) -> impl Future<Output = Option<F::Output>>;
What the client did, as it happens: for counters and logs. It must not fail or block, because the client does not wait for it.
An attempt is going out. retry is 0 for the first attempt and
for its "never sent" resends.
79 Sending { retry: u32 },
Attempt attempt failed with cause and is retried after delay.
81 Retrying { attempt: u32, delay: Duration, cause: &'a dyn fmt::Display, request_id: Option<&'a str> },
The request never left; it is resent at once on a fresh connection.
83 Redialing { cause: &'a TransportError },
A verified answer, after attempts attempts.
What happened, as far as retrying is concerned.
The request never reached the server: a connection that had already closed, or a stream refused (REFUSED_STREAM, or above a GOAWAY's last stream id). Resent at once on a new connection; it is not a retry, because nothing was billed.
102 NotSent,
Resolving or connecting failed. Retried.
104 Connect,
The exchange broke after the request may have been sent. Retried, and possibly billed twice (no idempotency key exists).
107 Interrupted,
TLS refused: bad certificate, no HTTP/2. Retrying cannot help.
109 Tls,
The response exceeded the size cap. Already produced and billed, so it is never retried.
112 TooLarge,
117impl TransportError { 118 pub fn new(kind: TransportErrorKind, message: impl Into<String>) -> Self { 119 TransportError { kind, message: message.into() } 120 } 121} 122 123impl fmt::Display for TransportError { 124 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 125 f.write_str(&self.message) 126 } 127} 128 129impl std::error::Error for TransportError {}