Skip to content

Commit

Permalink
Merge pull request #189 from swift-server-community/fix-warnings
Browse files Browse the repository at this point in the history
Fix EventLoop warnings
  • Loading branch information
0xTim committed Dec 6, 2023
2 parents 15dbd83 + f67efbf commit f36a793
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"3.0.0"),
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"4.0.0"),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.10.0"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.42.0"),
Expand Down
17 changes: 8 additions & 9 deletions Sources/APNS/APNSClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import NIOCore
import NIOHTTP1
import NIOSSL
import NIOTLS
import NIOPosix

/// A client to talk with the Apple Push Notification services.
public final class APNSClient<Decoder: APNSJSONDecoder, Encoder: APNSJSONEncoder>: APNSClientProtocol {
Expand Down Expand Up @@ -100,19 +101,17 @@ public final class APNSClient<Decoder: APNSJSONDecoder, Encoder: APNSJSONEncoder
httpClientConfiguration.httpVersion = .automatic
httpClientConfiguration.proxy = configuration.proxy

let httpClientEventLoopGroupProvider: HTTPClient.EventLoopGroupProvider

switch eventLoopGroupProvider {
case .shared(let eventLoopGroup):
httpClientEventLoopGroupProvider = .shared(eventLoopGroup)
self.httpClient = HTTPClient(
eventLoopGroupProvider: .shared(eventLoopGroup),
configuration: httpClientConfiguration
)
case .createNew:
httpClientEventLoopGroupProvider = .createNew
self.httpClient = HTTPClient(
configuration: httpClientConfiguration
)
}

self.httpClient = HTTPClient(
eventLoopGroupProvider: httpClientEventLoopGroupProvider,
configuration: httpClientConfiguration
)
}

/// Shuts down the client and event loop gracefully. This function is clearly an outlier in that it uses a completion
Expand Down
13 changes: 11 additions & 2 deletions Tests/APNSTests/APNSAuthenticationTokenManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@testable import APNSCore
import Crypto
import XCTest
import NIOConcurrencyHelpers

final class APNSAuthenticationTokenManagerTests: XCTestCase {
private static let signingKey = """
Expand Down Expand Up @@ -129,11 +130,19 @@ final class TestClock<Duration: DurationProtocol & Hashable>: Clock {
}

let minimumResolution: Duration = .zero
var now: Instant
private let _now: NIOLockedValueBox<Instant>

var now: Instant {
get {
self._now.withLockedValue { $0 }
} set {
self._now.withLockedValue { $0 = newValue }
}
}


public init(now: Instant = .init()) {
self.now = .init()
self._now = .init(now)
}

public func sleep(until deadline: Instant, tolerance: Duration? = nil) async throws {
Expand Down

0 comments on commit f36a793

Please sign in to comment.