@@ -22,6 +22,10 @@ import NIOTransportServices
22
22
import NIOSSL
23
23
#endif
24
24
25
+ #if canImport(Network)
26
+ import Network
27
+ #endif
28
+
25
29
@usableFromInline
26
30
internal protocol ConnectionManagerChannelProvider {
27
31
/// Make an `EventLoopFuture<Channel>`.
@@ -66,12 +70,62 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider {
66
70
internal var httpTargetWindowSize : Int
67
71
@usableFromInline
68
72
internal var httpMaxFrameSize : Int
73
+ @usableFromInline
74
+ internal var httpMaxResetStreams : Int
69
75
70
76
@usableFromInline
71
77
internal var errorDelegate : Optional < ClientErrorDelegate >
72
78
@usableFromInline
73
79
internal var debugChannelInitializer : Optional < ( Channel ) -> EventLoopFuture < Void > >
74
80
81
+ #if canImport(Network)
82
+ @available ( macOS 10 . 14 , iOS 12 . 0 , watchOS 6 . 0 , tvOS 12 . 0 , * )
83
+ @usableFromInline
84
+ internal var nwParametersConfigurator : ( @Sendable ( NWParameters ) -> Void ) ? {
85
+ get {
86
+ self . _nwParametersConfigurator as! ( @Sendable ( NWParameters ) -> Void ) ?
87
+ }
88
+ set {
89
+ self . _nwParametersConfigurator = newValue
90
+ }
91
+ }
92
+
93
+ private var _nwParametersConfigurator : ( any Sendable ) ?
94
+ #endif
95
+
96
+ #if canImport(Network)
97
+ @inlinable
98
+ @available ( macOS 10 . 14 , iOS 12 . 0 , watchOS 6 . 0 , tvOS 12 . 0 , * )
99
+ internal init (
100
+ connectionTarget: ConnectionTarget ,
101
+ connectionKeepalive: ClientConnectionKeepalive ,
102
+ connectionIdleTimeout: TimeAmount ,
103
+ tlsMode: TLSMode ,
104
+ tlsConfiguration: GRPCTLSConfiguration ? ,
105
+ httpTargetWindowSize: Int ,
106
+ httpMaxFrameSize: Int ,
107
+ httpMaxResetStreams: Int ,
108
+ errorDelegate: ClientErrorDelegate ? ,
109
+ debugChannelInitializer: ( ( Channel ) -> EventLoopFuture < Void > ) ? ,
110
+ nwParametersConfigurator: ( @Sendable ( NWParameters ) -> Void ) ?
111
+ ) {
112
+ self . init (
113
+ connectionTarget: connectionTarget,
114
+ connectionKeepalive: connectionKeepalive,
115
+ connectionIdleTimeout: connectionIdleTimeout,
116
+ tlsMode: tlsMode,
117
+ tlsConfiguration: tlsConfiguration,
118
+ httpTargetWindowSize: httpTargetWindowSize,
119
+ httpMaxFrameSize: httpMaxFrameSize,
120
+ httpMaxResetStreams: httpMaxResetStreams,
121
+ errorDelegate: errorDelegate,
122
+ debugChannelInitializer: debugChannelInitializer
123
+ )
124
+
125
+ self . nwParametersConfigurator = nwParametersConfigurator
126
+ }
127
+ #endif
128
+
75
129
@inlinable
76
130
internal init (
77
131
connectionTarget: ConnectionTarget ,
@@ -81,6 +135,7 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider {
81
135
tlsConfiguration: GRPCTLSConfiguration ? ,
82
136
httpTargetWindowSize: Int ,
83
137
httpMaxFrameSize: Int ,
138
+ httpMaxResetStreams: Int ,
84
139
errorDelegate: ClientErrorDelegate ? ,
85
140
debugChannelInitializer: ( ( Channel ) -> EventLoopFuture < Void > ) ?
86
141
) {
@@ -93,6 +148,7 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider {
93
148
94
149
self . httpTargetWindowSize = httpTargetWindowSize
95
150
self . httpMaxFrameSize = httpMaxFrameSize
151
+ self . httpMaxResetStreams = httpMaxResetStreams
96
152
97
153
self . errorDelegate = errorDelegate
98
154
self . debugChannelInitializer = debugChannelInitializer
@@ -130,9 +186,16 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider {
130
186
tlsConfiguration: configuration. tlsConfiguration,
131
187
httpTargetWindowSize: configuration. httpTargetWindowSize,
132
188
httpMaxFrameSize: configuration. httpMaxFrameSize,
189
+ httpMaxResetStreams: configuration. httpMaxResetStreams,
133
190
errorDelegate: configuration. errorDelegate,
134
191
debugChannelInitializer: configuration. debugChannelInitializer
135
192
)
193
+
194
+ #if canImport(Network)
195
+ if #available( macOS 10 . 14 , iOS 12 . 0 , watchOS 6 . 0 , tvOS 12 . 0 , * ) {
196
+ self . nwParametersConfigurator = configuration. nwParametersConfigurator
197
+ }
198
+ #endif
136
199
}
137
200
138
201
private var serverHostname : String ? {
@@ -203,6 +266,7 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider {
203
266
connectionIdleTimeout: self . connectionIdleTimeout,
204
267
httpTargetWindowSize: self . httpTargetWindowSize,
205
268
httpMaxFrameSize: self . httpMaxFrameSize,
269
+ httpMaxResetStreams: self . httpMaxResetStreams,
206
270
errorDelegate: self . errorDelegate,
207
271
logger: logger
208
272
)
@@ -222,6 +286,15 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider {
222
286
_ = bootstrap. connectTimeout ( connectTimeout)
223
287
}
224
288
289
+ #if canImport(Network)
290
+ if #available( macOS 10 . 14 , iOS 12 . 0 , watchOS 6 . 0 , tvOS 12 . 0 , * ) ,
291
+ let configurator = self . nwParametersConfigurator,
292
+ let transportServicesBootstrap = bootstrap as? NIOTSConnectionBootstrap
293
+ {
294
+ _ = transportServicesBootstrap. configureNWParameters ( configurator)
295
+ }
296
+ #endif
297
+
225
298
return bootstrap. connect ( to: self . connectionTarget)
226
299
}
227
300
}
0 commit comments