Example #1
0
        public async Task <HealthMonitorDto> GetHealth()
        {
            //todo needs refactoring
            var health = new HealthMonitorDto()
            {
                LastUpdated = DateTime.Now,
                AppName     = "Archimedes.Rabbit",
                Version     = "1.0.0",
                Url         = $"http://{_config.RabbitHost}:1{_config.RabbitPort}/"
            };

            try
            {
                var response = await _client.GetAsync("");

                health.Url = response.RequestMessage.RequestUri.ToString();

                if (!response.IsSuccessStatusCode)
                {
                    health.Status        = false;
                    health.StatusMessage = response.ReasonPhrase;
                    return(health);
                }

                health.Status        = true;
                health.StatusMessage = response.ReasonPhrase;
                health.LastActive    = DateTime.Now;
            }
            catch (Exception e)
            {
                health.Status = false;

                if (e.Message == "No connection could be made because the target machine actively refused it.")
                {
                    health.StatusMessage = "Refused";
                }
            }

            return(health);
        }
        public ActionResult <HealthMonitorDto> Get()
        {
            var health = new HealthMonitorDto()
            {
                AppName           = _config.ApplicationName,
                Version           = _config.AppVersion,
                LastActiveVersion = _config.AppVersion,
                Status            = true,
                LastUpdated       = DateTime.Now,
                LastActive        = DateTime.Now
            };

            try
            {
                return(Ok(health));
            }
            catch (Exception e)
            {
                _logger.LogError($"Error {e.Message} {e.StackTrace}");
                return(BadRequest("Error"));
            }
        }
 public async Task Add(HealthMonitorDto value)
 {
     await Clients.All.Add(value);
 }
 public async Task Update(HealthMonitorDto value)
 {
     await Clients.All.Update(value);
 }
 public async Task Delete(HealthMonitorDto value)
 {
     await Clients.All.Delete(value);
 }
 public Task Update(HealthMonitorDto health)
 {
     //_logger.LogInformation($"Update received from one of the strategy apis {health}");
     _context.Clients.All.SendAsync("Update", health);
     return(Task.CompletedTask);
 }
 public Task Delete(HealthMonitorDto health)
 {
     _context.Clients.All.SendAsync("Delete", health);
     return(Task.CompletedTask);
 }