Skip to content

Commit

Permalink
Merge pull request eclipse#152 from antoinesd/microprofile-health-36
Browse files Browse the repository at this point in the history
Add example where Health procedures are produced instead of defined by bean class
  • Loading branch information
antoinesd authored Dec 13, 2018
2 parents b4e0d33 + 2e5308b commit 7f1b3f0
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions spec/src/main/asciidoc/java-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public interface HealthCheck {
}
```

Applications provide health check procedures (implementation of a `HealthCheck`), which will be used by the
the runtime hosting the application to verify the healthiness of the computing node.
Applications provide health check procedures (implementation of a `HealthCheck`), which will be used by the runtime hosting the application to verify the healthiness of the computing node.

There can be one or several `HealthCheck` exposed, they will all be invoked when an inbound protocol request is received (i.e. HTTP).

Expand Down Expand Up @@ -102,3 +101,24 @@ public class MyCheck implements HealthCheck {
}
}
```

As health check procedures are CDI bean they can also be defined with CDI producers:


```
@ApplicationScoped
class MyChecks {

@Produces
@ApplicationScoped
HealthCheck check1() {
return () -> HealthStatus.state(getMemUsage() < 0.9);
}

@Produces
@ApplicationScoped
HealthCheck check2() {
return () -> HealthStatus.state(getCpuUsage() < 0.9);
}
}}
```

0 comments on commit 7f1b3f0

Please sign in to comment.