NetworkClientConfiguration

class NetworkClientConfiguration(val json: Json = DefaultKenworkJson, val authorizationProvider: AuthorizationProvider? = null, val maxAuthRefreshAttempts: Int = 1, val retryPolicy: RetryPolicy = DefaultRetryPolicy(), val reachabilityGate: ReachabilityGate? = null, val reachabilityWaitMillis: Long = DEFAULT_REACHABILITY_WAIT_MILLIS, val timeoutMillis: Long = DEFAULT_TIMEOUT_MILLIS, val retryDelayMillis: Long = DEFAULT_RETRY_DELAY_MILLIS, val logLevel: LogLevel = LogLevel.WARNING, val engineInterceptors: List<Interceptor> = emptyList(), val okHttpConfig: OkHttpClient.Builder.() -> Unit? = null, val okHttpCache: Cache? = null, val sslPinning: SslPinningConfiguration? = null, val engine: HttpClientEngine? = null, val eventListener: NetworkEventListener? = null, val requestInterceptor: RequestInterceptor? = null, val requestHeaderProvider: RequestHeaderProvider? = null)

Immutable configuration for a NetworkClient. Mirrors SwiftyNetwork's NetworkClientConfiguration.

Constructors

Link copied to clipboard
constructor(json: Json = DefaultKenworkJson, authorizationProvider: AuthorizationProvider? = null, maxAuthRefreshAttempts: Int = 1, retryPolicy: RetryPolicy = DefaultRetryPolicy(), reachabilityGate: ReachabilityGate? = null, reachabilityWaitMillis: Long = DEFAULT_REACHABILITY_WAIT_MILLIS, timeoutMillis: Long = DEFAULT_TIMEOUT_MILLIS, retryDelayMillis: Long = DEFAULT_RETRY_DELAY_MILLIS, logLevel: LogLevel = LogLevel.WARNING, engineInterceptors: List<Interceptor> = emptyList(), okHttpConfig: OkHttpClient.Builder.() -> Unit? = null, okHttpCache: Cache? = null, sslPinning: SslPinningConfiguration? = null, engine: HttpClientEngine? = null, eventListener: NetworkEventListener? = null, requestInterceptor: RequestInterceptor? = null, requestHeaderProvider: RequestHeaderProvider? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

supplies/refreshes credentials for requests without their own.

Link copied to clipboard
val engine: HttpClientEngine?

optional explicit Ktor engine; when set, the OkHttp-specific options above are ignored (used by tests to inject a MockEngine). When null, an OkHttp engine is built.

Link copied to clipboard
val engineInterceptors: List<Interceptor>

OkHttp interceptors (e.g. an APITrace recorder) added to the engine.

Link copied to clipboard

optional telemetry sink.

Link copied to clipboard
val json: Json

JSON codec used for (de)serialization.

Link copied to clipboard

verbosity of the Ktor request logger.

Link copied to clipboard

how many times to refresh-and-retry after a 401.

Link copied to clipboard
val okHttpCache: Cache?

optional OkHttp disk cache honoring backend Cache-Control/ETag.

Link copied to clipboard
val okHttpConfig: OkHttpClient.Builder.() -> Unit?

escape hatch to configure the underlying OkHttpClient.Builder directly (e.g. to install a bootstrap that needs the builder). Ignored when engine is set.

Link copied to clipboard

optional connectivity gate (e.g. networkMonitor.asReachabilityGate()): before each retry's backoff, the client waits up to reachabilityWaitMillis for connectivity, so retries park while offline instead of burning attempts. null disables the wait.

Link copied to clipboard

cap on how long a single retry waits on reachabilityGate.

Link copied to clipboard

optional hook supplying extra headers per attempt (see RequestHeaderProvider) — the place to inject trace-propagation headers (e.g. traceparent) read from whatever context the request interceptor made current for that attempt. null (the default) adds no headers.

Link copied to clipboard

optional hook wrapping each attempt (see RequestInterceptor) — the place to create a tracing span with an accurate start/end and propagate its context. null (the default) runs attempts directly, with no observable behavior change.

Link copied to clipboard

delay between a successful refresh and the retry.

Link copied to clipboard

decides whether/when to retry a failed request. Defaults to DefaultRetryPolicy (jittered exponential backoff for timeouts, lost connectivity, 429, and 5xx, honoring Retry-After). Supply your own or RetryPolicy.None to disable retries.

Link copied to clipboard

optional certificate pinning.

Link copied to clipboard

per-request timeout.