def attempt

bend-kit-hairpin@0.13.0.1 · hairpin.bend:386

import bend-kit-hairpin@0.13.0.1/hairpin.bend as Hairpin
import Base
import bend-kit-http@0.38.1.1/http.bend as Http
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import bend-kit-retry@0.2.0.0/retry.bend as Retry

386# Ask the gate; when it admits, make attempt n (0 first) of this layer. With no deadline and no breaker,
387# admission does not read the clock.
388def attempt(~R: Type, ~judge: Result<&1, &1, Http.Err, R> -> Result<&1, &1, Http.Err, R> & Verdict,
389    ~try: Opts -> Call -> Http.Pool -> Maybe<&2, Http.Jar> -> Bytes.Bytes -> IO(Http.Pool & Maybe<&2, Http.Jar> & Result<&1, &1, Http.Err, R>),
390    ~close: R -> IO(Unit),
391    +o: Opts, +call: Call, +idem: Bool, +n: Nat, s: Step<R>) -> IO(Step<R>):
392  Step{pool, jar, +br, +b, body, last, plan} = s
393  do IO<Step<R>>:
394    now : Nat <- clock(Bool.or(breaker.on(br), deadline.some(b)))
395    attempt.gate(~R, ~judge, ~try, ~close, Retry.admit(br, b, now), o, call, idem, n, pool, jar, body, last)

Uses (22)

Used by (1)