Пример #1
0
        public async Task <bool> HealthCheckAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation($"Health check Sv");

            try
            {
                return(await _grpcClient.HealthCheck(_grpcOptions.GetUri(), _healthCheckOptions.TimeoutSeconds, cancellationToken));
            }
            catch (Exception e)
            {
                _logger.LogError($"Error health check Sv", e);
                return(false);
            }
        }
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                _logger.LogInformation($"Heath check service running check");

                try
                {
                    await _grpcClientService.HealthCheck(_grpcOptions.GetUri(), _healthCheckOptions.TimeoutSeconds, stoppingToken);
                }
                catch (Exception e)
                {
                    _logger.LogInformation($"Heath check service error check", e);
                }

                await Task.Delay(5000, stoppingToken);
            }
        }