Skip to content

Commit 1579a9c

Browse files
authored
Fix preconcurrency warnings (#1480)
Motivation: NIO and Logging have now adopted Sendable so the `@preconcurrency` imports now emit warnings. Modifications: - Raise minimum required version to the versions with `Sendable` support - Remove `@preconcurrency` imports Result: No more warnings.
1 parent 428c5c3 commit 1579a9c

File tree

8 files changed

+29
-28
lines changed

8 files changed

+29
-28
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ let includeNIOSSL = ProcessInfo.processInfo.environment["GRPC_NO_NIO_SSL"] == ni
3232
let packageDependencies: [Package.Dependency] = [
3333
.package(
3434
url: "https://github.com/apple/swift-nio.git",
35-
from: "2.36.0"
35+
from: "2.41.1"
3636
),
3737
.package(
3838
url: "https://github.com/apple/swift-nio-http2.git",
@@ -52,7 +52,7 @@ let packageDependencies: [Package.Dependency] = [
5252
),
5353
.package(
5454
url: "https://github.com/apple/swift-log.git",
55-
from: "1.4.0"
55+
from: "1.4.4"
5656
),
5757
.package(
5858
url: "https://github.com/apple/swift-argument-parser.git",

Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerCallContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
#if compiler(>=5.6)
1717

18-
@preconcurrency import Logging
18+
import Logging
1919
import NIOConcurrencyHelpers
2020
import NIOHPACK
2121

Sources/GRPC/CallOptions.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@
1515
*/
1616
import struct Foundation.UUID
1717

18-
#if swift(>=5.6)
19-
@preconcurrency import Logging
20-
@preconcurrency import NIOCore
21-
#else
22-
import Logging
2318
import NIOCore
24-
#endif // swift(>=5.6)
2519

20+
import Logging
2621
import NIOHPACK
2722
import NIOHTTP1
2823
import NIOHTTP2

Sources/GRPC/ClientConnection.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@
1515
*/
1616
#if swift(>=5.6)
1717
@preconcurrency import Foundation
18-
@preconcurrency import Logging
19-
@preconcurrency import NIOCore
2018
#else
2119
import Foundation
22-
import Logging
23-
import NIOCore
2420
#endif // swift(>=5.6)
2521

22+
import Logging
23+
import NIOCore
2624
import NIOHPACK
2725
import NIOHTTP2
2826
#if canImport(NIOSSL)

Sources/GRPC/ConnectionKeepalive.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
#if swift(>=5.6)
17-
@preconcurrency import NIOCore
18-
#else
1916
import NIOCore
20-
#endif // swift(>=5.6)
2117

2218
/// Provides keepalive pings.
2319
///

Sources/GRPC/ConnectionPool/GRPCChannelPool.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
#if swift(>=5.6)
17-
@preconcurrency import Logging
18-
@preconcurrency import NIOCore
19-
#else
2016
import Logging
2117
import NIOCore
22-
#endif // swift(>=5.6)
2318
import NIOPosix
2419

2520
public enum GRPCChannelPool {

Sources/GRPC/PlatformSupport.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ public protocol ClientBootstrapProtocol {
121121

122122
func connectTimeout(_ timeout: TimeAmount) -> Self
123123
func channelOption<T>(_ option: T, value: T.Value) -> Self where T: ChannelOption
124+
125+
#if swift(>=5.7)
126+
@preconcurrency
127+
func channelInitializer(_ handler: @escaping @Sendable (Channel) -> EventLoopFuture<Void>) -> Self
128+
#else
124129
func channelInitializer(_ handler: @escaping (Channel) -> EventLoopFuture<Void>) -> Self
130+
#endif
125131
}
126132

127133
extension ClientBootstrapProtocol {
@@ -149,10 +155,25 @@ public protocol ServerBootstrapProtocol {
149155
func bind(unixDomainSocketPath: String) -> EventLoopFuture<Channel>
150156
func withBoundSocket(_ connectedSocket: NIOBSDSocket.Handle) -> EventLoopFuture<Channel>
151157

152-
func serverChannelInitializer(_ initializer: @escaping (Channel) -> EventLoopFuture<Void>) -> Self
158+
#if swift(>=5.7)
159+
@preconcurrency
160+
func serverChannelInitializer(
161+
_ handler: @escaping @Sendable (Channel) -> EventLoopFuture<Void>
162+
) -> Self
163+
#else
164+
func serverChannelInitializer(_ handler: @escaping (Channel) -> EventLoopFuture<Void>) -> Self
165+
#endif
166+
153167
func serverChannelOption<T>(_ option: T, value: T.Value) -> Self where T: ChannelOption
154168

155-
func childChannelInitializer(_ initializer: @escaping (Channel) -> EventLoopFuture<Void>) -> Self
169+
#if swift(>=5.7)
170+
@preconcurrency
171+
func childChannelInitializer(_ handler: @escaping @Sendable (Channel) -> EventLoopFuture<Void>)
172+
-> Self
173+
#else
174+
func childChannelInitializer(_ handler: @escaping (Channel) -> EventLoopFuture<Void>) -> Self
175+
#endif
176+
156177
func childChannelOption<T>(_ option: T, value: T.Value) -> Self where T: ChannelOption
157178
}
158179

Sources/GRPC/TimeLimit.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
import Dispatch
17-
#if swift(>=5.6)
18-
@preconcurrency import NIOCore
19-
#else
2017
import NIOCore
21-
#endif // swift(>=5.6)
2218

2319
/// A time limit for an RPC.
2420
///

0 commit comments

Comments
 (0)