Skip to content

Commit

Permalink
Make IndiePitcher sendable and use shared httpclient by default
Browse files Browse the repository at this point in the history
  • Loading branch information
petrpavlik committed Sep 30, 2024
1 parent 02c9543 commit 7b132c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Sources/IndiePitcherSwift/IndiePitcherSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import NIOFoundationCompat

/// IndiePitcher SDK.
/// This SDK is only intended for server-side Swift use. Do not embed the secret API key in client-side code for security reasons.
public struct IndiePitcher {
private let client: HTTPClient
public struct IndiePitcher: Sendable {
private let client: HTTPClient // is sendable / thread-safe
private let apiKey: String
private let requestTimeout: TimeAmount = .seconds(30)
private let maxResponseSize = 1024 * 1024 * 100

/// Creates a new instance of IndiePitcher SDK
/// - Parameters:
/// - client: Vapor's client instance to use to perform network requests.
/// - client: Vapor's client instance to use to perform network requests. Uses the shared client by default.
/// - apiKey: Your project's secret key.
public init(client: HTTPClient, apiKey: String) {
public init(client: HTTPClient = .shared, apiKey: String) {
self.client = client
self.apiKey = apiKey
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/IndiePitcherSwiftTests/IndiePitcherSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final class IndiePitcherSwiftTests: XCTestCase {
var indiePitcher: IndiePitcher!

override func setUp() async throws {
indiePitcher = IndiePitcher(client: .shared, apiKey: IP_SECRET_API_KEY)
indiePitcher = IndiePitcher(apiKey: IP_SECRET_API_KEY)
}

override func tearDown() async throws {
Expand Down

0 comments on commit 7b132c0

Please sign in to comment.