Skip to content

Adopt a custom shared client #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make the shared client private
  • Loading branch information
czechboy0 committed Sep 18, 2023
commit 22d55af82334fa4950c977ba6ba299215da6586c
7 changes: 4 additions & 3 deletions Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,18 @@ public struct AsyncHTTPClientTransport: ClientTransport {
/// in AsyncHTTPClient. Do not use this value directly, outside of
/// the `Configuration.init(client:timeout:)` initializer, as it will
/// likely be removed in the future.
public static let sharedClient: HTTPClient = .init()
private static let sharedClient: HTTPClient = .init()

/// The default request timeout.
public var timeout: TimeAmount

/// Creates a new configuration with the specified client and timeout.
/// - Parameters:
/// - client: The underlying client used to perform HTTP operations.
/// Provide nil to use the shared internal client.
/// - timeout: The request timeout, defaults to 1 minute.
public init(client: HTTPClient = Self.sharedClient, timeout: TimeAmount = .minutes(1)) {
self.client = client
public init(client: HTTPClient? = nil, timeout: TimeAmount = .minutes(1)) {
self.client = Self.sharedClient
self.timeout = timeout
}
}
Expand Down