From eff0c1fffed79c5696a8866d52ed52cb9c05f3b3 Mon Sep 17 00:00:00 2001 From: a179346 <38758138+a179346@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:07:32 +0800 Subject: [PATCH] docs: Add comments (#3) --- packages/core/src/index.ts | 25 ++++++++++++++++++++++ packages/http-probe-performer/package.json | 4 ++-- packages/http-probe-performer/src/index.ts | 14 ++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 190b59e..97c9843 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,6 +1,26 @@ import { forkJoin, Observable, race, repeat, switchMap, tap, timer } from 'rxjs'; +/*! + * @rxjs-probe/core + * + * rxjs-probe provides an interface similar to Kubernetes probes using RxJS to detect service health. + * + * [GitHub]: https://github.com/a179346/rxjs-probe + * [npm]: https://www.npmjs.com/package/@rxjs-probe/core + */ + +/** + * ProbePerformer is a class that defines how to perform a health check. + * + * Use this class to create a custom health check performer. + * + * Or leverage our predefined health check performers: + * - [HttpProbePerformer](https://www.npmjs.com/package/@rxjs-probe/http-probe-performer) + */ export class ProbePerformer { + /** + * A function that performs the health check. Throw an error if the health check fails. + */ protected readonly _runHealthCheck: (timeoutSeconds: number) => Promise | void; constructor(runHealthCheck: (timeoutSeconds: number) => Promise | void) { @@ -28,6 +48,11 @@ export class ProbePerformer { export type ProbeStatus = 'unknown' | 'healthy' | 'unhealthy'; +/** + * ProbeConfig is the configuration for a probe. + * + * Check the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes) for more information. + */ export interface ProbeConfig { performer: ProbePerformer; initialDelaySeconds?: number; diff --git a/packages/http-probe-performer/package.json b/packages/http-probe-performer/package.json index 3ed7725..efa3845 100644 --- a/packages/http-probe-performer/package.json +++ b/packages/http-probe-performer/package.json @@ -1,7 +1,7 @@ { "name": "@rxjs-probe/http-probe-performer", "version": "1.0.0-alpha.0", - "description": "The probe performer that send HTTP requests to perform the health check.", + "description": "The probe performer that send HTTP GET requests to perform the health check.", "keywords": [ "rxjs", "probe", @@ -41,4 +41,4 @@ "peerDependencies": { "@rxjs-probe/core": "*" } -} +} \ No newline at end of file diff --git a/packages/http-probe-performer/src/index.ts b/packages/http-probe-performer/src/index.ts index c12a2ac..49cb59d 100644 --- a/packages/http-probe-performer/src/index.ts +++ b/packages/http-probe-performer/src/index.ts @@ -1,5 +1,19 @@ import { ProbePerformer } from '@rxjs-probe/core'; +/*! + * @rxjs-probe/http-probe-performer + * + * The probe performer that send HTTP GET requests to perform the health check. + * + * [GitHub]: https://github.com/a179346/rxjs-probe + * [npm]: https://www.npmjs.com/package/@rxjs-probe/http-probe-performer + */ + +/** + * The configuration for the HTTP probe performer. + * + * Check the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#http-probes) for more information. + */ interface HttpProbePerformerConfig { host: string; scheme?: 'HTTP' | 'HTTPS';