licence_audit/httpc_adaptive
Keep this client until a replacement provides a bounded IPv6 probe and
remembers IPv4 fallback for the rest of the command. These are required
behaviors, not redundant wrappers around gleam_httpc.
An IPv6-only DNS nxdomain selects IPv4 silently; other probe failures warn.
#43 fixed repeated IPv6 timeouts. Removing this client in #61 brought them
back: gleam_httpc’s inet6fb4 path can exhaust the five-second Hex timeout
before IPv4 succeeds. The same endpoint responds promptly over IPv4.
Types
pub type ConnectionReason {
ConnectionTimedOut
DnsFailure
ConnectionRefused
NetworkUnreachable
HostUnreachable
}
Constructors
-
ConnectionTimedOut -
DnsFailure -
ConnectionRefused -
NetworkUnreachable -
HostUnreachable
pub type Error {
InvalidUtf8Response
ResponseTimeout
NoIpv6Address
FailedToConnect(reason: String)
RequestFailed(reason: String)
ConnectionFailure(reason: ConnectionReason, detail: String)
ConnectionClosed(reason: String)
TlsFailure(detail: String)
InvalidRequest(detail: String)
RetryWaitExceeded(wait_ms: Int, remaining_ms: Int)
HostUnavailable(host: String)
}
Constructors
-
InvalidUtf8Response -
ResponseTimeout -
NoIpv6Address -
FailedToConnect(reason: String) -
RequestFailed(reason: String) -
ConnectionFailure(reason: ConnectionReason, detail: String) -
ConnectionClosed(reason: String) -
TlsFailure(detail: String) -
InvalidRequest(detail: String) -
RetryWaitExceeded(wait_ms: Int, remaining_ms: Int) -
HostUnavailable(host: String)
Values
pub fn clear_host_failures(host: String) -> Nil
pub fn describe_error(error: Error, timeout_ms: Int) -> String
Keep transport diagnostics consistent across Hex and OSV.
pub fn dispatch(
request: request.Request(String),
timeout_ms timeout_ms: Int,
) -> Result(response.Response(String), Error)
pub fn dispatch_bits(
request: request.Request(BitArray),
timeout_ms timeout_ms: Int,
) -> Result(response.Response(BitArray), Error)
pub fn dispatch_bits_with(
request: request.Request(BitArray),
timeout_ms: Int,
client: fn(request.Request(BitArray), Int, IpFamily) -> Result(
response.Response(BitArray),
Error,
),
) -> Result(response.Response(BitArray), Error)
Inject the transport so fallback behavior can be tested without network I/O.
pub fn dispatch_managed_bits_with(
request: request.Request(BitArray),
timeout_ms: Int,
client: fn(request.Request(BitArray), Int, IpFamily) -> Result(
response.Response(BitArray),
Error,
),
) -> Result(response.Response(BitArray), Error)
Managed metadata calls must not turn TLS/input failures into IPv4 retries.
pub fn dispatch_retry(
request: request.Request(String),
timeout_ms: Int,
retries retries: Int,
) -> Result(response.Response(String), Error)
Retry one logical operation, not the IPv6 probe. Callers map errors only after this policy finishes, so retry decisions never inspect diagnostics.
pub fn dispatch_retry_with(
request: request.Request(a),
retries: Int,
client: fn(request.Request(a)) -> Result(
response.Response(b),
Error,
),
now: fn() -> Int,
elapsed: fn() -> Int,
sleep: fn(Int) -> Nil,
) -> Result(response.Response(b), Error)
Inject transport, wall clock, elapsed clock and sleep for deterministic tests.
pub fn record_host_failure(host: String) -> Nil
pub fn reset_retry_state() -> Nil
pub fn select_family(
request: request.Request(BitArray),
client: fn(request.Request(BitArray), Int, IpFamily) -> Result(
response.Response(BitArray),
Error,
),
) -> IpFamily
Reuse the command’s family selection with a bounded transport for the probe.
pub fn take_warning() -> option.Option(String)