UpstreamClientConfig
The configuration of an UpstreamClient: the receiver of the factory's lambda (Ktor's HttpClientConfig is the precedent). Stable Core. Not thread-safe; use it only inside the lambda.
Types
The default of defaultMaxWait.
Properties
The longest a call waits for a budget permit before it fails with HttpFailure.BudgetExhausted, which carries the wait the call would have needed. Defaults to 5 seconds (DEFAULT_MAX_WAIT), long enough to ride out a burst over a window of a few seconds and short enough that a person waiting on the call sees the failure before the transport's call timeout is added to it: a call's worst-case latency is this value plus the call timeout. A wait for a window of a minute or longer, or for a server-requested pause, is normally longer and fails at once. Use Duration.ZERO to never wait and Duration.INFINITE to wait as long as the plan needs (up to the budget's pause cap). A response-cache load shared by several callers waits with the cap of the caller that started it. Meaningful only with a budget that waits; CallBudget.Unlimited grants at once. A per-call CallSpec.maxWait overrides it. Not negative.
Where the owned cache's loads run. Dispatchers.Default by default. Unused by the common factory, which owns no cache, and when cache(...) was called.
The default request headers, copied into every call's headers (CallSpec.headers { } edits them). Put credentials here with addSensitive: they are never printed, an Untrusted policy refuses them, and the transport strips them on a cross-origin redirect. A header the transport controls (User-Agent, Host, …) is refused when the client is built. Empty by default.
The outbound-URL policy the client pre-checks every request with and the owning factory's transport enforces. Default: OutboundUrlPolicy.trusted { pinnedHosts = setOf(baseUrl.host) }, which allows only https on the base URL's host. Under an Untrusted policy a sensitive default header is refused when the client is built.
Reads rate signals from each response. RateSignalsReader.Standard by default; a per-provider reader implements the (opt-in) port.
Measures every wait and duration: the owned cache's lifetimes, the owned budget and the per-call log figures. TimeSource.Monotonic by default; a test passes VirtualClock.timeSource.
The wall clock the owned budget indexes its windows with and the signal reader resolves dates with. WallClock.System by default.
Functions
Uses budget, which the caller owns: the client never closes it. A later budget(...) call replaces an earlier one. Without any, the client uses CallBudget.Unlimited.
Builds a WindowedCallBudget over windows when the factory runs, after this whole lambda, and owns it: the client closes it. Its builder is seeded with this configuration's final timeSource and wallClock; then configure runs, so an explicit assignment there wins. A later budget(...) call replaces an earlier one.
Uses cache, which the caller owns: the client never closes it. Without this call the common factory uses ResponseCache.Disabled and the JVM owning factory builds and owns a CaffeineResponseCache. A later call replaces an earlier one.