Exemplo n.º 1
0
        internal ConnectionManager(
            Resolver resolver,
            bool disableResolverServiceConfig,
            ILoggerFactory loggerFactory,
            IBackoffPolicyFactory backoffPolicyFactory,
            ISubchannelTransportFactory subchannelTransportFactory,
            LoadBalancerFactory[] loadBalancerFactories)
        {
            _lock               = new object();
            _nextPickerTcs      = new TaskCompletionSource <SubchannelPicker>(TaskCreationOptions.RunContinuationsAsynchronously);
            _resolverStartedTcs = new TaskCompletionSource <object?>(TaskCreationOptions.RunContinuationsAsynchronously);

            Logger                       = loggerFactory.CreateLogger <ConnectionManager>();
            LoggerFactory                = loggerFactory;
            BackoffPolicyFactory         = backoffPolicyFactory;
            _subchannels                 = new List <Subchannel>();
            _stateWatchers               = new List <StateWatcher>();
            _resolver                    = resolver;
            DisableResolverServiceConfig = disableResolverServiceConfig;
            _subchannelTransportFactory  = subchannelTransportFactory;
            LoadBalancerFactories        = loadBalancerFactories;
        }
Exemplo n.º 2
0
        public DnsResolver(Uri address, int defaultPort, ILoggerFactory loggerFactory, TimeSpan refreshInterval, IBackoffPolicyFactory backoffPolicyFactory) : base(loggerFactory, backoffPolicyFactory)
        {
            _originalAddress = address;

            // DNS address has the format: dns:[//authority/]host[:port]
            // Because the host is specified in the path, the port needs to be parsed manually
            var addressParsed = new Uri("temp://" + address.AbsolutePath.TrimStart('/'));

            _dnsAddress      = addressParsed.Host;
            _port            = addressParsed.Port == -1 ? defaultPort : addressParsed.Port;
            _refreshInterval = refreshInterval;
            _logger          = loggerFactory.CreateLogger <DnsResolver>();
        }