call

suspend fun <T : Any> call(endpoint: Endpoint<T>, configure: CallSpec.() -> Unit = {}): Result<Lookup<T>>(source)

Calls endpoint.

A failure is never stored. Concurrent callers of one key share one load and receive the first caller's result, so the request sent is the first caller's. A negative maxAge never reaches the cache: it is an InvalidRequest.

Return

Found or Missing; otherwise a failure: HttpFailure.Closed ("client", or a component's), TransportFailure.InvalidRequest, TransportFailure.RefusedByPolicy, HttpFailure.BudgetExhausted, any TransportFailure, UpstreamFailure.RateLimited, UpstreamFailure.UpstreamError, HttpFailure.DecodeFailure or the decoder's own HttpFailure; an IllegalStateException when a cancellation escapes the load while the caller itself is not cancelled (the cache's rule).

Parameters

endpoint

the endpoint to call.

configure

sets this call's path, query, headers, method, body, lane, maxWait and maxAge; the defaults when omitted.

Type Parameters

T

the endpoint's value type.

Throws

kotlinx.coroutines.CancellationException

if the caller is cancelled (only that caller; a shared load continues for the others).

if the decoder, the reader, the transport or the budget's store throws one.