Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async health check #973

Closed
wants to merge 2 commits into from
Closed

Async health check #973

wants to merge 2 commits into from

Conversation

tomfitzhenry
Copy link

For issue #609

Proposed API for users is:

HealthCheckRegistry registry = new HealthCheckRegistry();
ScheduledExecutorService e = new ScheduledThreadPoolExecutor(1);
HealthCheck foo = ...
AsyncHealthCheck asyncFoo = new AsyncHealthCheck(foo, 2, TimeUnit.MINUTES);
e.scheduleWithFixedDelay(asyncFoo, 0, 30, TimeUnit.SECONDS);
registry.register("foo", asyncFoo)

In the above example, the ScheduledExecutorService will execute the health checks with 30s delay. The health check will fail if its cached result is older than 2 minutes.

Design choices:

  • Give user control over the async checking, so they can plug it into whatever executor service they have
  • Reads must be quick
  • Detect if the cached result is too old, and allow user to define what too old is

@tomfitzhenry
Copy link
Author

For users that are happy to cede control over the execution of the health check run() methods, perhaps HealthCheckRegister#registerAsync(HealthCheck, int refreshFrequency, TimeUnit refreshFrequencyUnit, int int staleAge, TimeUnit staleAgeUnit) could be added, which managed an internal ScheduledExecutorService

@ryantenney ryantenney closed this Jul 12, 2016
@ryantenney ryantenney reopened this Jul 12, 2016
@vbauer
Copy link

vbauer commented Jan 12, 2017

Any about this PR?... We'd like to have async-feature too

@arteam
Copy link
Member

arteam commented Feb 24, 2017

Contributed in #1077

@arteam arteam closed this Feb 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants