コード例 #1
0
        public void Start()
        {
            if (!_options.ShouldDiscover)
            {
                return;
            }
            _logger.LogDebug("Discovery worker is starting.");

            Task.Factory.StartNew(async() =>
            {
                try
                {
                    await _discoveryClient.DiscoverAsync();
                }
                catch (UnhealthyException ex)
                {
                    _isHealthy = false;
                    _logger.LogError(ex.InnerException ?? ex, ex.Message);
                    Restart();
                }
                catch (TimeoutException ex)
                {
                    _isHealthy = false;
                    _logger.LogError(ex.Message);
                    await Task.Delay(1000 * 30);
                    Restart();
                }
            }, _cts.Token);

            _dispather.Pumping();
        }