polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [2/4] polygene-java git commit: Added factory methods for HealthCheck result, and limited the constructor to private, to retain better control.
Date Sat, 25 Feb 2017 05:30:04 GMT
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/develop
Commit: d85f00fa78d648d79f25f304d25a87b28516eeda
Parents: 28f2e97
Author: niclas <niclas@spicter.com>
Authored: Sat Feb 25 13:28:11 2017 +0800
Committer: niclas <niclas@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;


Mime
View raw message