|
| 1 | +using IntegrationEngine.Scheduler; |
| 2 | +using IntegrationEngine.Core.Mail; |
| 3 | +using IntegrationEngine.Core.Storage; |
| 4 | +using IntegrationEngine.MessageQueue; |
| 5 | +using InEngineHealthStatus = IntegrationEngine.Model.HealthStatus; |
| 6 | +using Nest; |
| 7 | +using System; |
| 8 | +using System.Linq; |
| 9 | +using System.Collections.Generic; |
| 10 | +using System.Web.Http; |
| 11 | +using System.Web.Http.Description; |
| 12 | + |
| 13 | + |
| 14 | +namespace IntegrationEngine.Api.Controllers |
| 15 | +{ |
| 16 | + public class HealthStatusController : ApiController |
| 17 | + { |
| 18 | + public IMailClient MailClient { get; set; } |
| 19 | + public IMessageQueueClient MessageQueueClient { get; set; } |
| 20 | + public ESRepository<CronTrigger> ESRepository { get; set; } |
| 21 | + |
| 22 | + public HealthStatusController() |
| 23 | + {} |
| 24 | + |
| 25 | + public HealthStatusController(IMailClient mailClient, IMessageQueueClient messageQueueClient, ESRepository<CronTrigger> esRepository) |
| 26 | + : this() |
| 27 | + { |
| 28 | + MailClient = mailClient; |
| 29 | + MessageQueueClient = messageQueueClient; |
| 30 | + ESRepository = esRepository; |
| 31 | + } |
| 32 | + |
| 33 | + [ResponseType(typeof(InEngineHealthStatus))] |
| 34 | + public IHttpActionResult GetHealthStatus() |
| 35 | + { |
| 36 | + return Ok(new InEngineHealthStatus() { |
| 37 | + IsMailServerAvailable = MailClient.IsServerAvailable(), |
| 38 | + IsMessageQueueServerAvailable = MessageQueueClient.IsServerAvailable(), |
| 39 | + IsElasticsearchServerAvailable = ESRepository.IsServerAvailable(), |
| 40 | + }); |
| 41 | + } |
| 42 | + } |
| 43 | +} |
0 commit comments