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.singleCallTimeout = TimeLimit.timeout(.milliseconds(singleCallTimeout))
|
||||
|
||||
let configuration = ClientConnection.Configuration(
|
||||
target: .hostAndPort(host, port),
|
||||
eventLoopGroup: MultiThreadedEventLoopGroup(numberOfThreads: 1),
|
||||
connectivityStateDelegate: connectionManager,
|
||||
connectivityStateDelegateQueue: queue,
|
||||
tls: secure ? .init() : nil
|
||||
)
|
||||
let channel = ClientConnection(configuration: configuration)
|
||||
let connectionBuilder = secure ?
|
||||
ClientConnection.usingPlatformAppropriateTLS(for: MultiThreadedEventLoopGroup(numberOfThreads: 1)) :
|
||||
ClientConnection.insecure(group: MultiThreadedEventLoopGroup(numberOfThreads: 1))
|
||||
|
||||
let channel = connectionBuilder
|
||||
.withConnectivityStateDelegate(connectionManager, executingOn: queue)
|
||||
.withKeepalive(
|
||||
ClientConnectionKeepalive(
|
||||
interval: .seconds(15),
|
||||
timeout: .seconds(10)
|
||||
)
|
||||
)
|
||||
.connect(host: host, port: port)
|
||||
|
||||
self.channel = channel
|
||||
|
||||
|
|
|
@ -38,14 +38,21 @@ enum LightWalletEndpointBuilder {
|
|||
class ChannelProvider {
|
||||
func channel(secure: Bool = false) -> GRPCChannel {
|
||||
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