def retry.start

bend-kit-http@0.38.2.0 · http.bend:4600

import bend-kit-http@0.38.2.0/http.bend as Http
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

4600# fetch.retry(n, method, url, headers, body) is fetch, tried again up to n times while an
4601# idempotent method (GET, HEAD, OPTIONS, TRACE, PUT, DELETE) gets a connect error, a timeout,
4602# or 408, 429, 500, 502, 503, or 504. POST, PATCH and other methods get one try. It waits
4603# Retry-After (seconds or HTTP-date, at most 30 s) when given, else the backoff. When retries
4604# run out, the last response or error comes back as it was.
4605def retry.start(enabled: Bool, n: U32, +method: String, +url: String,
4606    +headers: Map<&2, List<&2, String>>, body: Bytes.Bytes) ->
4607    IO(Result<&1, &1, Err, Res>):
4608  match enabled:
4609    case False{}:
4610      fetch(method, url, headers, body)
4611    case True{}:
4612      do IO<Result<&1, &1, Err, Res>>:
4613        first : Bytes.Bytes & Result<&1, &1, Err, Res> & Maybe<&2, String> <-
4614          retry.one(True{}, method, url, headers, Bytes.slice(body, 0, 4294967295))
4615        retry.go(U32.to_nat(n), 0n, True{}, method, url, headers, first)

Uses (18)

Used by (1)