armeria
armeria copied to clipboard
HealthCheckService does not return dynamic messages or errors
A user of the HealthCheckService will often want to see additional information from a healthcheck about why a component is healthy/unhealthy along with an error. However, the HealthChecker
interface does not allow for that currently as it has a single (non-static) method boolean isHealthy()
.
We should support returning a Result
object with state (boolean), optional message (string) and optional error (throwable) from a HealthChecker. We would also need to add support for serialisation of the Result
to return in the HealthCheckService
responses.
I think this is a good idea 👍
Maybe we can add an option at HealthCheckServiceBuilder
whether to return a "verbose" health check response. We could make this option exclusive with the HealthCheckServiceBuilder#healthyResponse
and HealthCheckServiceBuilder#unhealthyResponse
options.
support returning a Result object with state (boolean), optional message (string) and optional error (throwable)
Curious about the distinction between message
and error
.
I was original thinking message
and error
would always be returned regardless of whether the health-check response is healthy or not.
Does this make sense for your use-case?
Or were you expecting error
is only included in the health-check response if a health check is unhealthy?
One option is that the Result contains an Optional error and that is set only when the health check is unhealthy.
Another option is that the error is empty ( null
) for healthy responses. Both will work for the use-case as the goal is to communicate additional info about the health of a component.
Both will work for the use-case as the goal is to communicate additional info about the health of a component.
I see. Would it also make sense for your use-case if Result
just has a single message
field in this case? (without the error
field)?