@Test void startShouldLogPeriodicallyWhenDegraded() { ListAppender<ILoggingEvent> loggingEvents = getListAppenderForClass(PeriodicalHealthChecks.class); TestingHealthCheck degraded = () -> Mono.just(Result.degraded(TestingHealthCheck.COMPONENT_NAME, "cause")); testee = new PeriodicalHealthChecks(ImmutableSet.of(degraded), scheduler, new PeriodicalHealthChecksConfiguration(PERIOD)); testee.start(); scheduler.advanceTimeBy(PERIOD); assertThat(loggingEvents.list).hasSize(1) .allSatisfy(loggingEvent -> { assertThat(loggingEvent.getLevel()).isEqualTo(Level.WARN); assertThat(loggingEvent.getFormattedMessage()).contains("DEGRADED", "testing", "cause"); }); }
public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) .flatMapIterable(any -> healthChecks) .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) .subscribe(); }
PeriodicalHealthChecks implements Startable { public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) .flatMapIterable(any -> healthChecks) .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) .subscribe(); } }
PeriodicalHealthChecks implements Startable { public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) .flatMapIterable(any -> healthChecks) .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) .subscribe(); } @Inject  PeriodicalHealthChecks(Set<HealthCheck> healthChecks, PeriodicalHealthChecksConfiguration configuration);   PeriodicalHealthChecks(Set<HealthCheck> healthChecks, Scheduler scheduler, PeriodicalHealthChecksConfiguration configuration); }
PeriodicalHealthChecks implements Startable { public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) .flatMapIterable(any -> healthChecks) .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) .subscribe(); } @Inject  PeriodicalHealthChecks(Set<HealthCheck> healthChecks, PeriodicalHealthChecksConfiguration configuration);   PeriodicalHealthChecks(Set<HealthCheck> healthChecks, Scheduler scheduler, PeriodicalHealthChecksConfiguration configuration); void start(); @PreDestroy void stop(); }
PeriodicalHealthChecks implements Startable { public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) .flatMapIterable(any -> healthChecks) .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) .subscribe(); } @Inject  PeriodicalHealthChecks(Set<HealthCheck> healthChecks, PeriodicalHealthChecksConfiguration configuration);   PeriodicalHealthChecks(Set<HealthCheck> healthChecks, Scheduler scheduler, PeriodicalHealthChecksConfiguration configuration); void start(); @PreDestroy void stop();  }