Skip to content
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

Fix EventLoop warnings #189

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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