def retry.start

bend-kit-http@0.38.5.0 · http.bend:4604

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

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

Uses (18)

Used by (1)