chibenwa commented on code in PR #2404:
URL: https://github.com/apache/james-project/pull/2404#discussion_r1754036199
##########
server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/HealthCheckRoutes.java:
##########
@@ -58,6 +58,38 @@
import spark.Service;
public class HealthCheckRoutes implements PublicRoutes {
+ public enum StatusCodeConvertMode {
+ STRICT(resultStatus -> {
+ switch (resultStatus) {
+ case HEALTHY:
+ return HttpStatus.OK_200;
+ case DEGRADED, UNHEALTHY:
+ return HttpStatus.SERVICE_UNAVAILABLE_503;
+ default:
+ throw new NotImplementedException(resultStatus + " is not
supported");
+ }
+ }),
+ RELAXED(resultStatus -> {
+ switch (resultStatus) {
+ case HEALTHY, DEGRADED:
+ return HttpStatus.OK_200;
+ case UNHEALTHY:
+ return HttpStatus.SERVICE_UNAVAILABLE_503;
+ default:
+ throw new NotImplementedException(resultStatus + " is not
supported");
+ }
+ });
+
+ private Function<ResultStatus, Integer> converter;
+
+ StatusCodeConvertMode(Function<ResultStatus, Integer> converter) {
+ this.converter = converter;
+ }
+
+ public Function<ResultStatus, Integer> getConverter() {
+ return converter;
+ }
Review Comment:
Exposing the function outside iss super verbose.
We have internally a function because the way enum work. But *please* do not
leak this to the outer code!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]