2014-02-26 05:40:47 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using NzbDrone.Core.Datastore.Events;
|
|
|
|
|
using NzbDrone.Core.HealthCheck;
|
|
|
|
|
using NzbDrone.Core.Messaging.Commands;
|
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Health
|
|
|
|
|
{
|
|
|
|
|
public class HealthModule : NzbDroneRestModuleWithSignalR<HealthResource, HealthCheck>,
|
2014-04-10 00:15:13 +00:00
|
|
|
|
IHandle<HealthCheckCompleteEvent>
|
2014-02-26 05:40:47 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly IHealthCheckService _healthCheckService;
|
|
|
|
|
|
|
|
|
|
public HealthModule(ICommandExecutor commandExecutor, IHealthCheckService healthCheckService)
|
|
|
|
|
: base(commandExecutor)
|
|
|
|
|
{
|
|
|
|
|
_healthCheckService = healthCheckService;
|
|
|
|
|
GetResourceAll = GetHealth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<HealthResource> GetHealth()
|
|
|
|
|
{
|
2014-04-10 00:15:13 +00:00
|
|
|
|
return ToListResource(_healthCheckService.Results);
|
2014-02-26 05:40:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-10 00:15:13 +00:00
|
|
|
|
public void Handle(HealthCheckCompleteEvent message)
|
2014-02-26 05:40:47 +00:00
|
|
|
|
{
|
|
|
|
|
BroadcastResourceChange(ModelAction.Sync);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|