def pool.give

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

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

2744# Past the limit (cap for HTTP/1.1, one session for HTTP/2), close the oldest idle connection.
2745def pool.give(p: Pool, +key: String, c: Conn) -> IO(Pool):
2746  Pool{+cap, idle} = p
2747  match c:
2748    case Conn{tls, s}:
2749      pool.give.of(cap, key, Conn{tls, s}, U32.to_nat(cap), Map.pop(&1, List<&1, Conn>, idle, key))
2750    case ConnH2{s, client}:
2751      pool.give.of(cap, key, ConnH2{s, client}, Bool.pick(Nat, U32.is_zero(cap), 0n, 1n),
2752        Map.pop(&1, List<&1, Conn>, idle, key))

Uses (11)

Used by (4)