Closes #404 This commit updates LightWalletGRPCService conform to latest Swift-GRPC recommendations on how to set Connections KeepAlive parameters. See https://github.com/grpc/grpc-swift/blob/main/docs/keepalive.md
This commit is contained in:
parent
acae6a0d7b
commit
79dbe8f387
|
@ -112,14 +112,19 @@ public class LightWalletGRPCService {
|
||||||
self.streamingCallTimeout = TimeLimit.timeout(.milliseconds(streamingCallTimeout))
|
self.streamingCallTimeout = TimeLimit.timeout(.milliseconds(streamingCallTimeout))
|
||||||
self.singleCallTimeout = TimeLimit.timeout(.milliseconds(singleCallTimeout))
|
self.singleCallTimeout = TimeLimit.timeout(.milliseconds(singleCallTimeout))
|
||||||
|
|
||||||
let configuration = ClientConnection.Configuration(
|
let connectionBuilder = secure ?
|
||||||
target: .hostAndPort(host, port),
|
ClientConnection.usingPlatformAppropriateTLS(for: MultiThreadedEventLoopGroup(numberOfThreads: 1)) :
|
||||||
eventLoopGroup: MultiThreadedEventLoopGroup(numberOfThreads: 1),
|
ClientConnection.insecure(group: MultiThreadedEventLoopGroup(numberOfThreads: 1))
|
||||||
connectivityStateDelegate: connectionManager,
|
|
||||||
connectivityStateDelegateQueue: queue,
|
let channel = connectionBuilder
|
||||||
tls: secure ? .init() : nil
|
.withConnectivityStateDelegate(connectionManager, executingOn: queue)
|
||||||
)
|
.withKeepalive(
|
||||||
let channel = ClientConnection(configuration: configuration)
|
ClientConnectionKeepalive(
|
||||||
|
interval: .seconds(15),
|
||||||
|
timeout: .seconds(10)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.connect(host: host, port: port)
|
||||||
|
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
|
|
||||||
|
|
|
@ -38,14 +38,21 @@ enum LightWalletEndpointBuilder {
|
||||||
class ChannelProvider {
|
class ChannelProvider {
|
||||||
func channel(secure: Bool = false) -> GRPCChannel {
|
func channel(secure: Bool = false) -> GRPCChannel {
|
||||||
let endpoint = LightWalletEndpointBuilder.default
|
let endpoint = LightWalletEndpointBuilder.default
|
||||||
|
|
||||||
let configuration = ClientConnection.Configuration(
|
|
||||||
target: .hostAndPort(endpoint.host, endpoint.port),
|
|
||||||
eventLoopGroup: MultiThreadedEventLoopGroup(numberOfThreads: 1),
|
|
||||||
tls: secure ? .init() : nil
|
|
||||||
)
|
|
||||||
|
|
||||||
return ClientConnection(configuration: configuration)
|
let connectionBuilder = secure ?
|
||||||
|
ClientConnection.usingPlatformAppropriateTLS(for: MultiThreadedEventLoopGroup(numberOfThreads: 1)) :
|
||||||
|
ClientConnection.insecure(group: MultiThreadedEventLoopGroup(numberOfThreads: 1))
|
||||||
|
|
||||||
|
let channel = connectionBuilder
|
||||||
|
.withKeepalive(
|
||||||
|
ClientConnectionKeepalive(
|
||||||
|
interval: .seconds(15),
|
||||||
|
timeout: .seconds(10)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.connect(host: endpoint.host, port: endpoint.port)
|
||||||
|
|
||||||
|
return channel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue