{"id":33179013,"url":"https://github.com/microprofile/microprofile-health","last_synced_at":"2026-02-23T09:59:10.803Z","repository":{"id":47008839,"uuid":"89364664","full_name":"microprofile/microprofile-health","owner":"microprofile","description":"microprofile-health","archived":false,"fork":false,"pushed_at":"2025-02-07T14:40:55.000Z","size":518,"stargazers_count":111,"open_issues_count":33,"forks_count":62,"subscribers_count":31,"default_branch":"main","last_synced_at":"2026-02-16T20:45:55.836Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microprofile.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":"CONTRIBUTING.adoc","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-25T13:36:45.000Z","updated_at":"2026-01-30T08:23:14.000Z","dependencies_parsed_at":"2025-02-07T15:44:24.545Z","dependency_job_id":null,"html_url":"https://github.com/microprofile/microprofile-health","commit_stats":null,"previous_names":["microprofile/microprofile-health","eclipse/microprofile-health"],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/microprofile/microprofile-health","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microprofile%2Fmicroprofile-health","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microprofile%2Fmicroprofile-health/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microprofile%2Fmicroprofile-health/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microprofile%2Fmicroprofile-health/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microprofile","download_url":"https://codeload.github.com/microprofile/microprofile-health/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microprofile%2Fmicroprofile-health/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29741144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-11-16T03:00:36.817Z","updated_at":"2026-02-23T09:59:09.688Z","avatar_url":"https://github.com/microprofile.png","language":"Java","funding_links":[],"categories":["容错组件"],"sub_categories":[],"readme":"//\n// Copyright (c) 2016-2021 Contributors to the Eclipse Foundation\n//\n// See the NOTICES file(s) distributed with this work for additional\n// information regarding copyright ownership.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\n\n= MicroProfile Health\n\n== Motivation\n\nHealth checks are used to probe the state of a computing node from another machine (i.e. kubernetes service controller) with the primary target being cloud infrastructure environments where automated processes maintain the state of computing nodes.\n\nIn this scenario, _health checks are used to determine if a computing node needs to be discarded (terminated, shutdown)_ and eventually replaced by another (healthy) instance.\n\nIt’s not intended (although could be used) as a monitoring solution for human operators.\n\n== Proposed solution\n\nThe proposed solution breaks down into two parts:\n\n- A health check protocol and wireformat\n- A Java API to implement health check procedures\n\n== Detailed design\n\n=== Protocol\n\nThis project defines a protocol (wireformat, semantics and possible forms of interactions) between system components that need to determine the “liveliness” of computing nodes in a bigger architecture.\nA detailed description of the health check protocol can be found in the link:https://github.com/eclipse/microprofile-health/tree/master/spec/src/main/asciidoc/protocol-wireformat.asciidoc[companion document].\n\n=== API Usage\n\nThe main API to provide health check procedures on the application level is the _HealthCheck_ interface:\n\n```java\n@FunctionalInterface\npublic interface HealthCheck {\n\n    HealthCheckResponse call();\n}\n```\n\nApplications are expected to provide health check procedures (implementation of a _HealthCheck_), which will be used by the framework or runtime hosting the application to verify the healthiness of the computing node.\n\nThe runtime will _call()_ the _HealthCheck_ which in turn creates a _HealthCheckResponse_ that signals the health status to a consuming end:\n\n```java\npublic class HealthCheckResponse {\n\n    public enum Status { UP, DOWN }\n\n    private final String name;\n    \n    private final Status status;\n    \n    private final Optional\u003cMap\u003cString, Object\u003e\u003e data;\n    \n    [...]\n}\n```\n\n=== Constructing HealthCheckResponse\n\nApplication level code is expected to use one of static methods on _HealthCheckResponse_ to retrieve a _HealthCheckResponseBuilder_ used to construct a response, i.e. :\n\n```java\npublic class SuccessfulCheck implements HealthCheck {\n    @Override\n    public HealthCheckResponse call() {\n        return HealthCheckResponse.up(\"successful-check\");\n    }\n}\n```\n\n== Different kinds of Health Checks\n\nThis specification provides different kinds of health check procedures.\nDifference between them is only semantic.\nThe nature of the procedure is defined by annotating the _HealthCheck_ procedure with a specific annotation.\n\n* Readiness checks defined with _@Readiness_ annotation\n* Liveness checks defined with _@Liveness_ annotation\n\nA _HealthCheck_ procedure with none of the above annotations is not an active procedure and should be ignored.\n\n=== Readiness check\n\nA Health Check for readiness allows third party services to know if the application is ready to process requests or not.\n\nThe _@Readiness_ annotation must be applied on a _HealthCheck_ implementation to define a readiness check procedure, otherwise, this annotation is ignored.\n\n=== Liveness check\n\nA Health Check for liveness allows third party services to determine if the application is running.\nThis means that if this procedure fails the application can be discarded (terminated, shutdown).\n\nThe _@Liveness_ annotation must be applied on a _HealthCheck_ implementation to define a Liveness check procedure, otherwise, this annotation is ignored.\n\n=== Startup check\n\nA Health check for startup allows applications to define startup probes that are used for initial verification of the application before the liveness probe takes over.\n\nThe _@Startup_ annotation must be applied on a _HealthCheck_ implementation to define a startup check procedure, otherwise, this annotation is ignored.\n\n\n== Integration with CDI\n\nAny enabled bean with a bean of type _org.eclipse.microprofile.health.HealthCheck_ and _@Liveness_, _@Readiness_, or _@Startup_ qualifier can be used as health check procedure.\n\n\nContextual references of health check procedures are invoked by runtime when the outermost protocol entry point (i.e. _http://HOST:PORT/health_) receives an inbound request\n\n\n```\n@ApplicationScoped\n@Liveness\n@Readiness\npublic class MyCheck implements HealthCheck {\n\n    public HealthCheckResponse call() {\n        [...]\n    }\n}\n```\n\nHealth check procedures are CDI beans, therefore, they can also be defined with CDI producers:\n\n\n```\n@ApplicationScoped\nclass MyChecks {\n\n  @Produces\n  @Liveness\n  HealthCheck check1() {\n    return () -\u003e HealthCheckResponse.named(\"heap-memory\").status(getMemUsage() \u003c 0.9).build();\n  }\n\n  @Produces\n  @Readiness\n  HealthCheck check2() {\n    return () -\u003e HealthCheckResponse.named(\"cpu-usage\").status(getCpuUsage() \u003c 0.9).build();\n  }\n  \n  @Produces\n  @Startup\n  HealthCheck check3() {\n    return () -\u003e HealthCheckResponse.named(\"initial-heap-memory\").status(getMemUsage() \u003c 0.95).build();\n  }\n}\n```\n\n== SPI Usage\n\nImplementors of the API are expected to supply implementations of _HealthCheckResponse_ and _HealthCheckResponseBuilder_ by providing a _HealthCheckResponseProvider_ to their implementation. The _HealthCheckResponseProvider_ is discovered using the default JDK service loader.\n\nA _HealthCheckResponseProvider_ is used internally to create a _HealthCheckResponseBuilder_ which is used to construct a _HealthCheckResponse_. This pattern allows implementors to extend a _HealthCheckResponse_ and adapt it to their implementation needs. Common implementation details that fall into this category are invocation and security contexts or anything else required to map a _HealthCheckResponse_ to the outermost invocation protocol (i.e. HTTP/JSON).\n\n== Contributing\n\nDo you want to contribute to this project? link:CONTRIBUTING.adoc[Find out how you can help here].\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicroprofile%2Fmicroprofile-health","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicroprofile%2Fmicroprofile-health","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicroprofile%2Fmicroprofile-health/lists"}