@jitar-plugins/eventbroker 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+
2
+ # Event Broker | Jitar Plugins
3
+
4
+ This package provides plugins for integrating the [The Shelf event broker package](https://github.com/MaskingTechnology/theshelf/tree/main/packages/eventbroker) in Jitar applications.
5
+
6
+ It contains a single health check for checking the event broker health.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @theshelf/eventbroker @jitar-plugins/eventbroker
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Follow the following steps to configure and use the provided health check.
17
+
18
+ ### Step 1 - Configure the health check
19
+
20
+ ```ts
21
+ // src/health/eventBrokerHealthCheck.ts
22
+
23
+ import eventBroker from '@theshelf/eventbroker';
24
+ import { EventBrokerHealthCheck } from '@jitar-plugins/eventbroker';
25
+
26
+ export default new EventBrokerHealthCheck(eventBroker);
27
+ ```
28
+
29
+ ### Step 2 - Activate the health check
30
+
31
+ With the health check in place, it needs to be activated by registering it to the worker / standalone service.
32
+
33
+ ```json
34
+ /* services/some-worker.json */
35
+ {
36
+ "url": "http://example.com:3000",
37
+ "healthChecks": [ /* add health checks here */
38
+ "./health/eventBrokerHealthCheck"
39
+ ],
40
+ "worker":
41
+ {
42
+ /* service configuration */
43
+ }
44
+ }
45
+ ```
@@ -0,0 +1,9 @@
1
+ import type { HealthCheck } from 'jitar';
2
+ import type { EventBroker } from '@theshelf/eventbroker';
3
+ export default class EventBrokerHealthCheck implements HealthCheck {
4
+ #private;
5
+ constructor(eventBroker: EventBroker);
6
+ get name(): string;
7
+ get timeout(): number;
8
+ isHealthy(): Promise<boolean>;
9
+ }
@@ -0,0 +1,13 @@
1
+ export default class EventBrokerHealthCheck {
2
+ #eventBroker;
3
+ #name = 'database';
4
+ #timeout = 5000;
5
+ constructor(eventBroker) {
6
+ this.#eventBroker = eventBroker;
7
+ }
8
+ get name() { return this.#name; }
9
+ get timeout() { return this.#timeout; }
10
+ async isHealthy() {
11
+ return this.#eventBroker.connected;
12
+ }
13
+ }
@@ -0,0 +1 @@
1
+ export { default as EventBrokerHealthCheck } from './EventBrokerHealthCheck';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default as EventBrokerHealthCheck } from './EventBrokerHealthCheck';
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@jitar-plugins/eventbroker",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "clean": "rimraf dist",
9
+ "lint": "eslint",
10
+ "review": "npm run build && npm run lint",
11
+ "prepublishOnly": "npm run build"
12
+ },
13
+ "files": [
14
+ "README.md",
15
+ "dist"
16
+ ],
17
+ "types": "dist/index.d.ts",
18
+ "exports": "./dist/index.js",
19
+ "peerDependencies": {
20
+ "@theshelf/eventbroker": "^0.0.2",
21
+ "jitar": "^0.10.3"
22
+ }
23
+ }