You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/02/26 22:47:30 UTC

[08/50] [abbrv] polygene-java git commit: Added factory methods for HealthCheck result, and limited the constructor to private, to retain better control.

Added factory methods for HealthCheck result, and limited the constructor to private, to retain better control.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/d85f00fa
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/d85f00fa
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/d85f00fa

Branch: refs/heads/serialization-3.0
Commit: d85f00fa78d648d79f25f304d25a87b28516eeda
Parents: 28f2e97
Author: niclas <ni...@spicter.com>
Authored: Sat Feb 25 13:28:11 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Sat Feb 25 13:28:11 2017 +0800

----------------------------------------------------------------------
 .../api/metrics/MetricsHealthCheck.java         | 26 +++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/d85f00fa/core/api/src/main/java/org/apache/polygene/api/metrics/MetricsHealthCheck.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/metrics/MetricsHealthCheck.java b/core/api/src/main/java/org/apache/polygene/api/metrics/MetricsHealthCheck.java
index e65703c..560667d 100644
--- a/core/api/src/main/java/org/apache/polygene/api/metrics/MetricsHealthCheck.java
+++ b/core/api/src/main/java/org/apache/polygene/api/metrics/MetricsHealthCheck.java
@@ -34,13 +34,37 @@ public interface MetricsHealthCheck extends Metric
         private final String message;
         private final Throwable exception;
 
-        public Result( boolean isHealthy, String message, Throwable exception )
+        private Result( boolean isHealthy, String message, Throwable exception )
         {
             healthy = isHealthy;
             this.message = message;
             this.exception = exception;
         }
 
+        /** Factory method for reporting an Ok health.
+         *
+         * @return A healthy result.
+         */
+        public static Result healthOk() {
+            return new Result( true, "", null );
+        }
+
+        /** Factory method for reporting an unhealthy state.
+         *
+         * @return An unhealthy result.
+         */
+        public static Result unhealthy(String message) {
+            return new Result( false, message, null );
+        }
+
+        /** Factory method for reporting a state where an exception has occurred.
+         *
+         * @return A failing health state.
+         */
+        public static Result exception(String message, Throwable exception) {
+            return new Result( false, message, exception );
+        }
+
         public boolean isHealthy()
         {
             return healthy;