[#541] Initialise gRPC on a separate thread (#545)

MultiThreadedEventLoopGroup has been replaced with NIOTSEventLoopGroup. It's recommended by authors of grpc-swift especially for iOS platform and it allows us to set the priority because NIOTSEventLoopGroup is GCD based while MultiThreadedEventLoopGroup is pthread based.

[#541] Initialise gRPC on a separate thread (#545)

- priority increased to .default
This commit is contained in:
Lukas Korba 2022-10-03 20:54:43 +02:00 committed by GitHub
parent 46d8c04afc
commit fa5bbbb2bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -10,6 +10,7 @@ import Foundation
import GRPC
import NIO
import NIOHPACK
import NIOTransportServices
public typealias Channel = GRPC.GRPCChannel
@ -127,8 +128,8 @@ public class LightWalletGRPCService {
self.singleCallTimeout = TimeLimit.timeout(.milliseconds(singleCallTimeout))
let connectionBuilder = secure ?
ClientConnection.usingPlatformAppropriateTLS(for: MultiThreadedEventLoopGroup(numberOfThreads: 1)) :
ClientConnection.insecure(group: MultiThreadedEventLoopGroup(numberOfThreads: 1))
ClientConnection.usingPlatformAppropriateTLS(for: NIOTSEventLoopGroup(loopCount: 1, defaultQoS: .default)) :
ClientConnection.insecure(group: NIOTSEventLoopGroup(loopCount: 1, defaultQoS: .default))
let channel = connectionBuilder
.withConnectivityStateDelegate(connectionManager, executingOn: queue)

View File

@ -11,6 +11,7 @@ import GRPC
import ZcashLightClientKit
import XCTest
import NIO
import NIOTransportServices
enum Environment {
static let lightwalletdKey = "LIGHTWALLETD_ADDRESS"
@ -40,8 +41,8 @@ class ChannelProvider {
let endpoint = LightWalletEndpointBuilder.default
let connectionBuilder = secure ?
ClientConnection.usingPlatformAppropriateTLS(for: MultiThreadedEventLoopGroup(numberOfThreads: 1)) :
ClientConnection.insecure(group: MultiThreadedEventLoopGroup(numberOfThreads: 1))
ClientConnection.usingPlatformAppropriateTLS(for: NIOTSEventLoopGroup(loopCount: 1, defaultQoS: .default)) :
ClientConnection.insecure(group: NIOTSEventLoopGroup(loopCount: 1, defaultQoS: .default))
let channel = connectionBuilder
.withKeepalive(