Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
            }));
        }
Exemplo n.º 4
0
        private (string host, int port) ExtractHostInfo(MachineLocation machineLocation)
        {
            var info = machineLocation.ExtractHostInfo();

            return(info.host, info.port ?? _configuration.GrpcPort);
        }