public HealthcheckScheduledJob(IFindHealthcheckEndpointsQuery findHealthcheckEndpointsQuery,
                                IReportHealth reportHealth,
                                IHealthcheckClient healthcheckClient)
 {
     _healthcheckEndpointsQuery = findHealthcheckEndpointsQuery;
     _reportHealth      = reportHealth;
     _healthcheckClient = healthcheckClient;
 }
示例#2
0
 public Healthcheck(HealthcheckEndpoint healthcheckEndpoint,
                    IReportHealth reportHealth,
                    IHealthcheckClient healthcheckClient)
 {
     _healthcheckEndpoint = healthcheckEndpoint;
     _healthcheckClient   = healthcheckClient;
     _reportHealth        = reportHealth;
 }
示例#3
0
        public static IMonitorActionFactory <T>[] ForQueue <T>(IReportHealth reporter, string name = null, long snapshotWhen = 0, long overflowWhen = 500, TimeSpan?sampleTime = null)
        {
            name = name == null ? reporter.ReporterName : "{0}.{1}".FormatWith(reporter.ReporterName, name);

            var overflow    = new BackpressureAction <T>(c => c > overflowWhen, (t, current) => reporter.Pulse.OnNext(new QueueOverflowEvent(name, current)), TimeSpan.FromMinutes(5));
            var snapshot    = new BackpressureAction <T>(c => c > snapshotWhen, (t, current) => reporter.Pulse.OnNext(new QueueSnapshotEvent(name, TimeSpan.FromSeconds(1), current)), sampleTime ?? TimeSpan.FromSeconds(15));
            var countPerSec = new StreamTimerAction <T>((count) => reporter.Pulse.OnNext(new QueueSpeedEvent(name, count)), sampleTime ?? TimeSpan.FromSeconds(15));


            return(new IMonitorActionFactory <T>[]
            {
                snapshot,
                overflow,
                countPerSec
            });
        }
示例#4
0
 public IHealthEvent Tunnel(IReportHealth another)
 {
     ReporterName = "{0}.{1}".FormatWith(another.ReporterName, ReporterName);
     return(this);
 }
示例#5
0
 public static IDisposable ReportsWith(this IReportHealth reporter, IReportHealth target)
 {
     return(reporter.Pulse.Subscribe(p => target.Pulse.OnNext(p.Tunnel(target))));
 }
示例#6
0
        private HealthcheckScheduledJob CreateHealthcheckJob(IFindHealthcheckEndpointsQuery findHealthcheckQuery = null, IReportHealth reportHealth = null, IHealthcheckClient healthcheckClient = null)
        {
            if (findHealthcheckQuery == null)
            {
                var findHealtcheckQueryBuilder = new FindHealthcheckEndpointsQueryBuilder();
                findHealthcheckQuery = findHealtcheckQueryBuilder.Build();
            }

            if (reportHealth == null)
            {
                reportHealth = Substitute.For <IReportHealth>();
            }

            if (healthcheckClient == null)
            {
                healthcheckClient = Substitute.For <IHealthcheckClient>();

                healthcheckClient.GetHealthcheck(Arg.Any <Uri>())
                .Returns(new HttpResponseMessage(HttpStatusCode.OK));
            }

            return(new HealthcheckScheduledJob(findHealthcheckQuery, reportHealth, healthcheckClient));
        }