Skip to content

Commit 4405796

Browse files
committed
Change API to allow only customisation of NWParameters, not bootstraps
1 parent 36f6b80 commit 4405796

File tree

5 files changed

+23
-31
lines changed

5 files changed

+23
-31
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ let packageDependencies: [Package.Dependency] = [
4040
),
4141
.package(
4242
url: "https://github.com/apple/swift-nio-transport-services.git",
43-
from: "1.15.0"
43+
from: "1.24.0"
4444
),
4545
.package(
4646
url: "https://github.com/apple/swift-nio-extras.git",

Sources/GRPC/ClientConnection.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ import Foundation
3333
import NIOSSL
3434
#endif
3535

36+
#if canImport(Network)
37+
import Network
38+
#endif
39+
3640
/// Provides a single, managed connection to a server which is guaranteed to always use the same
3741
/// `EventLoop`.
3842
///
@@ -472,13 +476,9 @@ extension ClientConnection {
472476
#if canImport(Network)
473477
/// A closure allowing to customise the `NWParameters` used when establising a connection using NIOTransportServices.
474478
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
475-
public var nwParametersConfigurator: (
476-
@Sendable (NIOTSConnectionBootstrap) -> Void
477-
)? {
479+
public var nwParametersConfigurator: (@Sendable (NWParameters) -> Void)? {
478480
get {
479-
return self._nwParametersConfigurator as! (
480-
@Sendable (NIOTSConnectionBootstrap) -> Void
481-
)?
481+
self._nwParametersConfigurator as! (@Sendable (NWParameters) -> Void)?
482482
}
483483
set {
484484
self._nwParametersConfigurator = newValue

Sources/GRPC/ConnectionManagerChannelProvider.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import NIOTransportServices
2222
import NIOSSL
2323
#endif
2424

25+
#if canImport(Network)
26+
import Network
27+
#endif
28+
2529
@usableFromInline
2630
internal protocol ConnectionManagerChannelProvider {
2731
/// Make an `EventLoopFuture<Channel>`.
@@ -75,13 +79,9 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider {
7579
#if canImport(Network)
7680
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
7781
@usableFromInline
78-
internal var nwParametersConfigurator: (
79-
@Sendable (NIOTSConnectionBootstrap) -> Void
80-
)? {
82+
internal var nwParametersConfigurator: (@Sendable (NWParameters) -> Void)? {
8183
get {
82-
return self._nwParametersConfigurator as! (
83-
@Sendable (NIOTSConnectionBootstrap) -> Void
84-
)?
84+
self._nwParametersConfigurator as! (@Sendable (NWParameters) -> Void)?
8585
}
8686
set {
8787
self._nwParametersConfigurator = newValue
@@ -104,7 +104,7 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider {
104104
httpMaxFrameSize: Int,
105105
errorDelegate: ClientErrorDelegate?,
106106
debugChannelInitializer: ((Channel) -> EventLoopFuture<Void>)?,
107-
nwParametersConfigurator: (@Sendable (NIOTSConnectionBootstrap) -> Void)?
107+
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
108108
) {
109109
self.init(
110110
connectionTarget: connectionTarget,
@@ -269,8 +269,8 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider {
269269
#if canImport(Network)
270270
if #available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *),
271271
let configurator = self.nwParametersConfigurator,
272-
let niotsBootstrap = bootstrap as? NIOTSConnectionBootstrap {
273-
configurator(niotsBootstrap)
272+
let transportServicesBootstrap = bootstrap as? NIOTSConnectionBootstrap {
273+
_ = transportServicesBootstrap.configureNWParameters(configurator)
274274
}
275275
#endif
276276

Sources/GRPC/ConnectionPool/GRPCChannelPool.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import NIOCore
1818
import NIOPosix
1919

2020
#if canImport(Network)
21-
import NIOTransportServices
21+
import Network
2222
#endif
2323

2424
import struct Foundation.UUID
@@ -322,13 +322,9 @@ extension GRPCChannelPool.Configuration {
322322

323323
/// A closure allowing to customise the `NWParameters` used when establising a connection using NIOTransportServices.
324324
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
325-
public var nwParametersConfigurator: (
326-
@Sendable (NIOTSConnectionBootstrap) -> Void
327-
)? {
325+
public var nwParametersConfigurator: (@Sendable (NWParameters) -> Void)? {
328326
get {
329-
return self._nwParametersConfigurator as! (
330-
@Sendable (NIOTSConnectionBootstrap) -> Void
331-
)?
327+
self._nwParametersConfigurator as! (@Sendable (NWParameters) -> Void)?
332328
}
333329
set {
334330
self._nwParametersConfigurator = newValue

Sources/GRPC/Server.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ public final class Server: @unchecked Sendable {
129129
}
130130

131131
if #available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *),
132-
let nwParametersConfigurator = configuration.nwParametersConfigurator,
132+
let configurator = configuration.nwParametersConfigurator,
133133
let transportServicesBootstrap = bootstrap as? NIOTSListenerBootstrap {
134-
nwParametersConfigurator(transportServicesBootstrap)
134+
_ = transportServicesBootstrap.configureNWParameters(configurator)
135135
}
136136
#endif // canImport(Network)
137137

@@ -393,13 +393,9 @@ extension Server {
393393
#if canImport(Network)
394394
/// A closure allowing to customise the `NWParameters` used when establising a connection using NIOTransportServices.
395395
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
396-
public var nwParametersConfigurator: (
397-
@Sendable (NIOTSListenerBootstrap) -> Void
398-
)? {
396+
public var nwParametersConfigurator: (@Sendable (NWParameters) -> Void)? {
399397
get {
400-
return self._nwParametersConfigurator as! (
401-
@Sendable (NIOTSListenerBootstrap) -> Void
402-
)?
398+
self._nwParametersConfigurator as! (@Sendable (NWParameters) -> Void)?
403399
}
404400
set {
405401
self._nwParametersConfigurator = newValue

0 commit comments

Comments
 (0)