You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by GitBox <gi...@apache.org> on 2019/09/07 17:26:18 UTC

[GitHub] [tomee] emecas commented on a change in pull request #557: Adding mp-custom-healthcheck Spanish Transalation

emecas commented on a change in pull request #557: Adding mp-custom-healthcheck Spanish Transalation
URL: https://github.com/apache/tomee/pull/557#discussion_r321977038
 
 

 ##########
 File path: examples/mp-custom-healthcheck/README_es.adoc
 ##########
 @@ -0,0 +1,160 @@
+= MicroProfile Custom Health Check
+:index-group: MicroProfile
+:jbake-type: page
+:jbake-status: published
+
+Este es un ejemplo sobre cómo usar el MicroProfile Custom Health Check en TomEE.
+
+[discrete]
+==== Health Feature
+
+Los Health checks se usan para probar el estado de los servicios y los recursos de los que una aplicación depende, incluso para exponer su estado. Por ejemplo, en un ambiente de clúster, donde un nodo inestable requiere ser descartado y eventualmente ser remplazado por una instancia estable.
+
+Por defecto, https://github.com/eclipse/microprofile-health[microprofile-health-api] proporciona la salida de un nodo, simplemente accediendo el end point http://host:port/health.
+
+
+[source,json]
+----
+{"checks":[],"outcome":"UP","status":"UP"}
+----
+
+Para proporcionar una salida a la medida , por ejemplo, si tenemos una aplicación que usa un API de clima, y el servicio se cae, podemos reportar que el servicio esta caído (DOWN).
+
+Es necesario implementar la interface  https://github.com/eclipse/microprofile-health/blob/master/api/src/main/java/org/eclipse/microprofile/health/HealthCheck.java[HealthCheck], en una clase con la anotación `@ApplicationScoped` y la anotación`@Health` para proporcionar la salida a la medida.
+
+Se pueden ver más detalles aquí: https://github.com/apache/geronimo-health/blob/master/geronimo-health/src/main/java/org/apache/geronimo/microprofile/impl/health/cdi/GeronimoHealthExtension.java[GeronimoHealthExtension.java]
+
+
+[source,java]
+----
+@Health
+@ApplicationScoped
+public class WeatherServiceHealthCheck implements HealthCheck {
+
+    @Inject WeatherGateway weatherGateway;
+
+    @Override
+    public HealthCheckResponse call() {
+        HealthCheckResponseBuilder responseBuilder = HealthCheckResponse.named("OpenWeatherMap");
+        try {
+            WeatherApiStatus status = weatherGateway.getApiStatus();
+            return responseBuilder.withData("weatherServiceApiUrl", status.getUrl())
+                    .withData("weatherServiceApiVersion", status.getVersion())
+                    .withData("weatherServiceMessage", status.getMessage())
+                    .up().build();
+        } catch (WeatherException e) {
+            return responseBuilder.withData("weatherServiceErrorMessage", e.getMessage()).down().build();
+        }
+    }
+}
+----
+
+En el anterior ejemplo, el health end point es: https://openweathermap.org/appid[OpenWeatherMap] (_solamente ilustrativo_) que proporciona una suscripción al plan para acceder los servicios y si el limite de llamadas a la API se excede no estará disponible hasta que se renueve las suscripción.
 
 Review comment:
    I have never read "health end point" as "sonda de salud", I would use more something like: "enlace de estado"

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services