Skip to content

Commit

Permalink
docs: Add comments (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
a179346 authored Sep 18, 2024
1 parent ade3ca5 commit eff0c1f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
25 changes: 25 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -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> | void;

constructor(runHealthCheck: (timeoutSeconds: number) => Promise<void> | void) {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/http-probe-performer/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -41,4 +41,4 @@
"peerDependencies": {
"@rxjs-probe/core": "*"
}
}
}
14 changes: 14 additions & 0 deletions packages/http-probe-performer/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down

0 comments on commit eff0c1f

Please sign in to comment.