Skip to content

Commit 25e1447

Browse files
committed
Updates
1 parent 209c62f commit 25e1447

File tree

5 files changed

+15
-26
lines changed

5 files changed

+15
-26
lines changed

.github/workflows/swift.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ on:
44
jobs:
55
focal:
66
container:
7-
image: swift:5.7-focal
7+
image: swift:6.0-focal
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v1
1111
- run: swift test --enable-test-discovery
1212
thread:
1313
container:
14-
image: swift:5.7-focal
14+
image: swift:6.0-focal
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v1
1818
- run: swift test --enable-test-discovery --sanitize=thread
1919
address:
2020
container:
21-
image: swift:5.7-focal
21+
image: swift:6.0-focal
2222
runs-on: ubuntu-latest
2323
steps:
2424
- uses: actions/checkout@v1

Package.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.9
1+
// swift-tools-version:6.0
22
import PackageDescription
33

44
let package = Package(
@@ -31,6 +31,7 @@ let package = Package(
3131
dependencies: [
3232
.target(name: "APNSCore"),
3333
.target(name: "APNS"),
34+
.product(name: "Logging", package: "swift-log"),
3435
]
3536
),
3637
.testTarget(

Sources/APNS/APNSClient.swift

+3-13
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,9 @@ public final class APNSClient<Decoder: APNSJSONDecoder, Encoder: APNSJSONEncoder
114114
}
115115
}
116116

117-
/// Shuts down the client and event loop gracefully. This function is clearly an outlier in that it uses a completion
118-
/// callback instead of an EventLoopFuture. The reason for that is that NIO's EventLoopFutures will call back on an event loop.
119-
/// The virtue of this function is to shut the event loop down. To work around that we call back on a DispatchQueue
120-
/// instead.
121-
///
122-
/// - Important: This will only shutdown the event loop if the provider passed to the client was ``createNew``.
123-
/// For shared event loops the owner of the event loop is responsible for handling the lifecycle.
124-
///
125-
/// - Parameters:
126-
/// - queue: The queue on which the callback is invoked on.
127-
/// - callback: The callback that is invoked when everything is shutdown.
128-
public func shutdown(queue: DispatchQueue = .global(), callback: @Sendable @escaping (Error?) -> Void) {
129-
self.httpClient.shutdown(callback)
117+
/// Shuts down the client and event loop gracefully.
118+
public func shutdown() async throws {
119+
try await self.httpClient.shutdown()
130120
}
131121
}
132122

Sources/APNSCore/APNSClient.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ import Dispatch
1616

1717
public protocol APNSClientProtocol {
1818
func send(_ request: APNSRequest<some APNSMessage>) async throws -> APNSResponse
19-
func shutdown(queue: DispatchQueue, callback: @Sendable @escaping (Error?) -> Void)
19+
func shutdown() async throws
2020
}

Sources/APNSExample/Program.swift

+6-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import APNSCore
1616
import APNS
17-
import OSLog
17+
import Logging
1818
import Foundation
1919

2020
@available(macOS 11.0, *)
@@ -30,8 +30,10 @@ struct Main {
3030
static let keyIdentifier = ""
3131
static let teamIdentifier = ""
3232

33+
private static let logger = Logger(label: "APNSwiftExample")
34+
3335
static func main() async throws {
34-
let logger = Logger(subsystem: "apns", category: "apns-main")
36+
3537
let client = APNSClient(
3638
configuration: .init(
3739
authenticationMethod: .jwt(
@@ -55,14 +57,10 @@ struct Main {
5557
try await Self.sendVoIP(with: client)
5658
try await Self.sendFileProvider(with: client)
5759
} catch {
58-
logger.warning("error sending push:\(error)")
60+
logger.warning("error sending push: \(error)")
5961
}
6062

61-
client.shutdown { error in
62-
if let error = error {
63-
logger.warning("error shutting down client: \(error.localizedDescription)")
64-
}
65-
}
63+
try? await client.shutdown()
6664
}
6765
}
6866

0 commit comments

Comments
 (0)