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

Provide a way to implement a HealthChecker with peioric polling easily. #3392

Closed
trustin opened this issue Mar 14, 2021 · 1 comment
Closed
Milestone

Comments

@trustin
Copy link
Member

trustin commented Mar 14, 2021

A user wants to implement a HealthChecker that updates its healthiness by polling an external source (e.g. database) periodically, so that HealthChecker.isHealthy() merely returns a cached value. This is mainly because:

  • HealthChecker.isHealthy() that takes long time can make a server look unhealthy.
  • Each health check request triggers HealthChecker.isHealthy(), and thus it is suboptimal to actually check the health of the external source.

It'd be nice if we provide a utility that simplifies the implementation of this pattern, e.g.

HealthChecker.ofFixedRate(Supplier<CompletionStage<Boolean>> healthChecker, Duration interval, double jitter)
HealthChecker.ofFixedDelay(Supplier<CompletionStage<Boolean>> healthChecker, Duration delay, double jitter)

Discussion at Slack: https://line-armeria.slack.com/archives/C1NGPBUH2/p1615691261133800

@trustin
Copy link
Member Author

trustin commented Mar 14, 2021

Alternatively, we could keep the timestamp of last healthChecker.get() and return the cached result only when the recorded timestamp is old enough. This is simpler to manage because we don't have to schedule a periodic task using an event loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant