Skip to content

Commit 0b43ce5

Browse files
authored
Revert "Add Sendable conformances to WebsocketKit (#131)" (#135)
This reverts commit c2e0aa4.
1 parent c2e0aa4 commit 0b43ce5

12 files changed

+172
-205
lines changed

.github/workflows/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ concurrency:
55
on:
66
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
77
push: { branches: [ main ] }
8+
89
jobs:
10+
911
vapor-integration:
1012
if: ${{ !(github.event.pull_request.draft || false) }}
1113
runs-on: ubuntu-latest

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
DerivedData
66
.swiftpm
77
Package.resolved
8-
.devcontainer/

Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ let package = Package(
1616
.package(url: "https://github.com/apple/swift-nio.git", from: "2.53.0"),
1717
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.16.0"),
1818
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.24.0"),
19-
.package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.16.0"),
20-
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.1.0"),
19+
.package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.11.4"),
20+
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.2"),
2121
],
2222
targets: [
2323
.target(name: "WebSocketKit", dependencies: [

Sources/WebSocketKit/Concurrency/WebSocket+Concurrency.swift

+19-27
Original file line numberDiff line numberDiff line change
@@ -40,42 +40,34 @@ extension WebSocket {
4040
try await close(code: code).get()
4141
}
4242

43-
public func onText(_ callback: @Sendable @escaping (WebSocket, String) async -> ()) {
44-
self.eventLoop.execute {
45-
self.onText { socket, text in
46-
Task {
47-
await callback(socket, text)
48-
}
43+
public func onText(_ callback: @escaping (WebSocket, String) async -> ()) {
44+
onText { socket, text in
45+
Task {
46+
await callback(socket, text)
4947
}
5048
}
5149
}
5250

53-
public func onBinary(_ callback: @Sendable @escaping (WebSocket, ByteBuffer) async -> ()) {
54-
self.eventLoop.execute {
55-
self.onBinary { socket, binary in
56-
Task {
57-
await callback(socket, binary)
58-
}
51+
public func onBinary(_ callback: @escaping (WebSocket, ByteBuffer) async -> ()) {
52+
onBinary { socket, binary in
53+
Task {
54+
await callback(socket, binary)
5955
}
6056
}
6157
}
6258

63-
public func onPong(_ callback: @Sendable @escaping (WebSocket) async -> ()) {
64-
self.eventLoop.execute {
65-
self.onPong { socket in
66-
Task {
67-
await callback(socket)
68-
}
59+
public func onPong(_ callback: @escaping (WebSocket) async -> ()) {
60+
onPong { socket in
61+
Task {
62+
await callback(socket)
6963
}
7064
}
7165
}
7266

73-
public func onPing(_ callback: @Sendable @escaping (WebSocket) async -> ()) {
74-
self.eventLoop.execute {
75-
self.onPing { socket in
76-
Task {
77-
await callback(socket)
78-
}
67+
public func onPing(_ callback: @escaping (WebSocket) async -> ()) {
68+
onPing { socket in
69+
Task {
70+
await callback(socket)
7971
}
8072
}
8173
}
@@ -85,7 +77,7 @@ extension WebSocket {
8577
headers: HTTPHeaders = [:],
8678
configuration: WebSocketClient.Configuration = .init(),
8779
on eventLoopGroup: EventLoopGroup,
88-
onUpgrade: @Sendable @escaping (WebSocket) async -> ()
80+
onUpgrade: @escaping (WebSocket) async -> ()
8981
) async throws {
9082
return try await self.connect(
9183
to: url,
@@ -105,7 +97,7 @@ extension WebSocket {
10597
headers: HTTPHeaders = [:],
10698
configuration: WebSocketClient.Configuration = .init(),
10799
on eventLoopGroup: EventLoopGroup,
108-
onUpgrade: @Sendable @escaping (WebSocket) async -> ()
100+
onUpgrade: @escaping (WebSocket) async -> ()
109101
) async throws {
110102
return try await self.connect(
111103
to: url,
@@ -129,7 +121,7 @@ extension WebSocket {
129121
headers: HTTPHeaders = [:],
130122
configuration: WebSocketClient.Configuration = .init(),
131123
on eventLoopGroup: EventLoopGroup,
132-
onUpgrade: @Sendable @escaping (WebSocket) async -> ()
124+
onUpgrade: @escaping (WebSocket) async -> ()
133125
) async throws {
134126
return try await self.connect(
135127
scheme: scheme,

Sources/WebSocketKit/Exports.swift

+4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
@_documentation(visibility: internal) @_exported import protocol NIOCore.EventLoopGroup
77
@_documentation(visibility: internal) @_exported import struct NIOCore.EventLoopPromise
88
@_documentation(visibility: internal) @_exported import class NIOCore.EventLoopFuture
9+
910
@_documentation(visibility: internal) @_exported import struct NIOHTTP1.HTTPHeaders
11+
1012
@_documentation(visibility: internal) @_exported import struct Foundation.URL
1113

1214
#else
@@ -17,7 +19,9 @@
1719
@_exported import protocol NIOCore.EventLoopGroup
1820
@_exported import struct NIOCore.EventLoopPromise
1921
@_exported import class NIOCore.EventLoopFuture
22+
2023
@_exported import struct NIOHTTP1.HTTPHeaders
24+
2125
@_exported import struct Foundation.URL
2226

2327
#endif

Sources/WebSocketKit/WebSocket+Connect.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension WebSocket {
1717
headers: HTTPHeaders = [:],
1818
configuration: WebSocketClient.Configuration = .init(),
1919
on eventLoopGroup: EventLoopGroup,
20-
onUpgrade: @Sendable @escaping (WebSocket) -> ()
20+
onUpgrade: @escaping (WebSocket) -> ()
2121
) -> EventLoopFuture<Void> {
2222
guard let url = URL(string: url) else {
2323
return eventLoopGroup.any().makeFailedFuture(WebSocketClient.Error.invalidURL)
@@ -45,7 +45,7 @@ extension WebSocket {
4545
headers: HTTPHeaders = [:],
4646
configuration: WebSocketClient.Configuration = .init(),
4747
on eventLoopGroup: EventLoopGroup,
48-
onUpgrade: @Sendable @escaping (WebSocket) -> ()
48+
onUpgrade: @escaping (WebSocket) -> ()
4949
) -> EventLoopFuture<Void> {
5050
let scheme = url.scheme ?? "ws"
5151
return self.connect(
@@ -83,7 +83,7 @@ extension WebSocket {
8383
headers: HTTPHeaders = [:],
8484
configuration: WebSocketClient.Configuration = .init(),
8585
on eventLoopGroup: EventLoopGroup,
86-
onUpgrade: @Sendable @escaping (WebSocket) -> ()
86+
onUpgrade: @escaping (WebSocket) -> ()
8787
) -> EventLoopFuture<Void> {
8888
return WebSocketClient(
8989
eventLoopGroupProvider: .shared(eventLoopGroup),
@@ -129,7 +129,7 @@ extension WebSocket {
129129
proxyConnectDeadline: NIODeadline = NIODeadline.distantFuture,
130130
configuration: WebSocketClient.Configuration = .init(),
131131
on eventLoopGroup: EventLoopGroup,
132-
onUpgrade: @Sendable @escaping (WebSocket) -> ()
132+
onUpgrade: @escaping (WebSocket) -> ()
133133
) -> EventLoopFuture<Void> {
134134
return WebSocketClient(
135135
eventLoopGroupProvider: .shared(eventLoopGroup),
@@ -171,7 +171,7 @@ extension WebSocket {
171171
proxyConnectDeadline: NIODeadline = NIODeadline.distantFuture,
172172
configuration: WebSocketClient.Configuration = .init(),
173173
on eventLoopGroup: EventLoopGroup,
174-
onUpgrade: @Sendable @escaping (WebSocket) -> ()
174+
onUpgrade: @escaping (WebSocket) -> ()
175175
) -> EventLoopFuture<Void> {
176176
guard let url = URL(string: url) else {
177177
return eventLoopGroup.any().makeFailedFuture(WebSocketClient.Error.invalidURL)

0 commit comments

Comments
 (0)