protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _logger.LogInformation("Starting worker for sending health beat to Saturn at endpoint " + _options.CurrentValue.SaturnEndpoint);
            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    while (await _channel.GetChannel().Reader.WaitToReadAsync())
                    {
                        using var call = _client.Push();
                        if (_channel.GetChannel().Reader.TryRead(out HealthCheckRequest healthCheckRequest))
                        {
                            await call.RequestStream.WriteAsync(healthCheckRequest);
                        }
                        await call.RequestStream.CompleteAsync();

                        var serverResponse = await call.ResponseAsync;
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError("There are some problems when trying to send HealthCheck", ex.ToString());
                }
            }
        }
Exemple #2
0
 public async Task PushHealthCheck(HealthCheckRequest healthCheckRequest)
 {
     if (_monitorOptions.CurrentValue.NotifyOptions.Enable)
     {
         try
         {
             healthCheckRequest.ServiceId = serviceId;
             await _monitoHeartBeatChannel.GetChannel().Writer.WriteAsync(healthCheckRequest);
         }
         catch (Exception ex)
         {
             throw new Exception("There are some erros when trying to notify monitor behavior in Service Management, please check stack trace.", ex);
         }
     }
 }