Package ratpack.core.health
Class HealthCheck.Result
- java.lang.Object
-
- ratpack.core.health.HealthCheck.Result
-
- Enclosing interface:
- HealthCheck
public static class HealthCheck.Result extends Object
The result of a health check. Instances can be created by one of the static methods of this class (e.g.healthy()
).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Throwable
getError()
The exception representing an unhealthy check, may benull
.String
getMessage()
Any message provided as part of the check, may benull
.static HealthCheck.Result
healthy()
Creates a healthy result, with no message.static HealthCheck.Result
healthy(String message)
Creates a healthy result, with the given message.static HealthCheck.Result
healthy(String message, Object... args)
Creates a healthy result, with the given message.boolean
isHealthy()
Was the component being checked healthy?static HealthCheck.Result
unhealthy(String message)
Creates an unhealthy result, with the given message.static HealthCheck.Result
unhealthy(String message, Object... args)
Creates an unhealthy result, with the given message.static HealthCheck.Result
unhealthy(String message, Throwable error)
Creates an unhealthy result, with the given exception and message.static HealthCheck.Result
unhealthy(Throwable error)
Creates an unhealthy result, with the given exception.
-
-
-
Method Detail
-
isHealthy
public boolean isHealthy()
Was the component being checked healthy?- Returns:
true
if application component is healthy
-
getMessage
@Nullable public String getMessage()
Any message provided as part of the check, may benull
.A message may be provided with a healthy or unhealthy result.
If
getError()
is non null, this message will be the message provided by that exception.- Returns:
- any message provided as part of the check, may be
null
-
getError
@Nullable public Throwable getError()
The exception representing an unhealthy check, may benull
.Healthy results will never have an associated error.
- Returns:
- the exception representing an unhealthy check, may be
null
-
healthy
public static HealthCheck.Result healthy()
Creates a healthy result, with no message.- Returns:
- a healthy result, with no message.
-
healthy
public static HealthCheck.Result healthy(String message)
Creates a healthy result, with the given message.- Parameters:
message
- a message to accompany the result- Returns:
- a healthy result, with the given message
-
healthy
public static HealthCheck.Result healthy(String message, Object... args)
Creates a healthy result, with the given message.The message is constructed by
String.format(String, Object...)
and the given arguments.- Parameters:
message
- the message format stringsargs
- values to be interpolated into the format string- Returns:
- a healthy result, with the given message
-
unhealthy
public static HealthCheck.Result unhealthy(String message)
Creates an unhealthy result, with the given message.- Parameters:
message
- a message to accompany the result- Returns:
- an unhealthy result, with the given message
-
unhealthy
public static HealthCheck.Result unhealthy(String message, Object... args)
Creates an unhealthy result, with the given message.The message is constructed by
String.format(String, Object...)
and the given arguments.- Parameters:
message
- the message format stringsargs
- values to be interpolated into the format string- Returns:
- an unhealthy result, with the given message
-
unhealthy
public static HealthCheck.Result unhealthy(Throwable error)
Creates an unhealthy result, with the given exception.The message of the given exception will also be used as the message of the result.
- Parameters:
error
- an exception thrown during health check- Returns:
- an unhealthy result, with the given error
-
unhealthy
public static HealthCheck.Result unhealthy(String message, Throwable error)
Creates an unhealthy result, with the given exception and message.The supplied message will be used as the message of the result.
- Parameters:
message
- a message to accompany the resulterror
- an exception thrown during health check- Returns:
- an unhealthy result, with the given error and message
- Since:
- 1.2
-
-