Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,22 @@ public struct AsyncHTTPClientTransport: ClientTransport {
/// The HTTP client used for performing HTTP calls.
public var client: HTTPClient

/// The default shared HTTP client.
///
/// This is a workaround for the lack of a shared client
/// 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()

/// 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.
/// - timeout: The request timeout, defaults to 1 minute.
public init(client: HTTPClient = .init(), timeout: TimeAmount = .minutes(1)) {
public init(client: HTTPClient = Self.sharedClient, timeout: TimeAmount = .minutes(1)) {
self.client = client
self.timeout = timeout
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,8 @@ class Test_AsyncHTTPClientTransport: XCTestCase {
}

func testSend() async throws {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let httpClient = HTTPClient(
eventLoopGroupProvider: .shared(eventLoopGroup),
configuration: .init()
)
defer {
try! httpClient.syncShutdown()
}
let transport = AsyncHTTPClientTransport(
configuration: .init(client: httpClient),
configuration: .init(),
requestSender: TestSender.test
)
let request: OpenAPIRuntime.Request = .init(
Expand Down