@cloudnative/health-connect

中文文档
2.1.0发布于 2019/09/25Apache-2.0CommonJS近 30 天下载 6.3万

Connect middleware for Cloud Health

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

原始使用文档
文档目录5 节
  1. Using Cloud Health Connect
  2. Using Cloud Health with Node.js
  3. Using Cloud Health Connect with Typescript
  4. Module Long Term Support Policy
  5. License

Cloud Health Connect

npm Build status Coverage Status Greenkeeper Module LTS Adopted IBM Support

Cloud Health Connect provides a Connect Middleware for use in Express.js, Loopback and other frameworks that uses Cloud Health to provide:

  • Readiness checks
  • Liveness checks
  • Combined Health (Readiness and Liveness) checks
  • Shutdown handling

to enable applications for use with Kubernetes and Cloud Foundry based clouds.

Using Cloud Health Connect

Cloud Health Connect takes the status reported by Cloud Health and makes it available on the liveness and/or readiness URL endpoints that the middleware is configured to use.

The middleware writes the data returned by the Cloud Health module as JSON, and sets the HTTP Status Code as follows:

Cloud Health StatusReadiness Status CodeLiveness Status CodeCombined Health Status Code
STARTING503 UNAVAILABLE200 OK503 UNAVAILABLE
UP200 OK200 OK200 OK
DOWN503 UNAVAILABLE503 UNAVAILABLE503 UNAVAILABLE
STOPPING503 UNAVAILABLE503 UNAVAILABLE503 UNAVAILABLE
STOPPED503 UNAVAILABLE503 UNAVAILABLE503 UNAVAILABLE
-500 SERVER ERROR500 SERVER ERROR500 SERVER ERROR

Using Cloud Health with Node.js

  1. Installation:
npm install @cloudnative/health-connect
  1. Set up a HealthChecker:
const health = require('@cloudnative/health-connect');
let healthcheck = new health.HealthChecker();
  1. Register a separate Liveness endpoint:
app.use('/live', health.LivenessEndpoint(healthcheck))

If no livessness checks are registered, this will report 200 OK and UP.

  1. Register a separate readiness endpoint:
app.use('/ready', health.ReadinessEndpoint(healthcheck))

If no readiness checks are registered, this will report 200 OK and UP.

  1. Register a combined health endpoint:
app.use('/health', health.HealthEndpoint(healthcheck))

If no readiness or liveness checks are registered, this will report 200 OK and UP.

For information on how to register startup, readiness, liveness and shutdown checks, see the Cloud Health documentation.

Health, Liveness and Readiness endpoints

The difference between liveness and readiness endpoints is the purpose: readiness should be used to denote whether an application is "ready" to receive requests, and liveness should be used to denote whether an application is "live" (vs. in a state where it should be restarted.

The combined health endpoint is designed for cloud technologies, such as Cloud Foundry which only support a single endpoint for both liveness and readiness checking.

Using Cloud Health Connect with Typescript

The Cloud Health Connect module is created in TypeScript and as such provides out of the box TypeScript support.

Module Long Term Support Policy

This module adopts the Module Long Term Support (LTS) policy, with the following End Of Life (EOL) dates:

Module VersionRelease DateMinimum EOLEOL WithStatus
2.x.xMay 2019April 2021Current
1.x.xJuly 2018Dec 2019LTS

License

Apache-2.0

版本与发布记录

@cloudnative/health-connect 共发布 6 个版本,首次发布于 2018/07/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.0latest2019/09/257 年前
2.0.02019/05/177 年前
1.0.22018/12/047 年前
1.0.12018/12/037 年前
1.0.02018/07/248 年前
0.0.12018/07/198 年前

关于 @cloudnative/health-connect 的常见问题

@cloudnative/health-connect 是什么?

Connect middleware for Cloud Health注意:该包已被作者标记为弃用——Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

如何安装 @cloudnative/health-connect?

在项目目录运行 npm install @cloudnative/health-connect,或使用 pnpm add / yarn add / bun add。

@cloudnative/health-connect 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cloudnative__health-connect 是否存在。

@cloudnative/health-connect 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cloudnative/health-connect 可以商用吗?

@cloudnative/health-connect 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cloudnative/health-connect 的下载量有多少?

根据 npm 官方下载统计,@cloudnative/health-connect 在 2026/10/10 – 2026/11/08 这 30 天内被下载 62,554 次,日均约 2,085 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cloudnative/health-connect 还在维护吗?

最新版本 2.1.0 发布于 2019/09/25(7 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/07/19。作者已将其标记为弃用,新项目建议寻找替代方案。