public ConnectionHandle(MachineLocation location, ConnectionPoolConfiguration configuration) { Location = location; _configuration = configuration; var hostInfo = location.ExtractHostInfo(); Host = hostInfo.host; Port = hostInfo.port ?? _configuration.DefaultPort; Channel = new Channel(Host, Port, ChannelCredentials.Insecure); }
private (string host, int port) ExtractHostInfo(MachineLocation machineLocation) { var info = machineLocation.ExtractHostInfo(); bool?encryptionEnabled = _configuration?.GrpcCopyClientCacheConfiguration?.GrpcCopyClientConfiguration?.GrpcCoreClientOptions?.EncryptionEnabled; if (encryptionEnabled == true) { return(info.host, _configuration.EncryptedGrpcPort); } return(info.host, info.port ?? _configuration.GrpcPort); }
private Task <Result <ClientHandle> > ConnectAsync(OperationContext context, MachineId machineId, MachineLocation machineLocation) { return(context.PerformOperationAsync( Tracer, async() => { var hostInfo = machineLocation.ExtractHostInfo(); var channel = new Channel(hostInfo.host, hostInfo.port ?? _configuration.Port, ChannelCredentials.Insecure); var client = channel.CreateGrpcService <T>(ClientFactory.Create(MetadataServiceSerializer.BinderConfiguration)); var handle = new ClientHandle(client, channel, machineId, machineLocation); await channel.ConnectAsync(DateTime.UtcNow + _configuration.ConnectTimeout); return Result.Success(handle); })); }
private (string host, int port) ExtractHostInfo(MachineLocation machineLocation) { var info = machineLocation.ExtractHostInfo(); return(info.host, info.port ?? _configuration.GrpcPort); }