@hotmeshio/hotmesh 0.29.1 → 0.31.0

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.
Files changed (65) hide show
  1. package/README.md +43 -0
  2. package/build/index.d.ts +2 -1
  3. package/build/index.js +3 -1
  4. package/build/modules/enums.d.ts +35 -0
  5. package/build/modules/enums.js +41 -1
  6. package/build/modules/errors.d.ts +26 -2
  7. package/build/modules/errors.js +82 -1
  8. package/build/modules/utils.d.ts +8 -0
  9. package/build/modules/utils.js +19 -1
  10. package/build/package.json +1 -1
  11. package/build/services/activities/trigger.js +3 -1
  12. package/build/services/connector/health.d.ts +42 -0
  13. package/build/services/connector/health.js +100 -0
  14. package/build/services/connector/index.js +2 -1
  15. package/build/services/connector/providers/postgres-resilient-client.d.ts +95 -0
  16. package/build/services/connector/providers/postgres-resilient-client.js +446 -0
  17. package/build/services/connector/providers/postgres.d.ts +6 -0
  18. package/build/services/connector/providers/postgres.js +72 -14
  19. package/build/services/durable/client.js +11 -3
  20. package/build/services/durable/handle.js +101 -41
  21. package/build/services/durable/worker.js +12 -4
  22. package/build/services/durable/workflow/condition.d.ts +14 -0
  23. package/build/services/durable/workflow/condition.js +14 -0
  24. package/build/services/engine/completion.js +3 -3
  25. package/build/services/engine/signal.js +3 -3
  26. package/build/services/escalations/batch.d.ts +7 -3
  27. package/build/services/escalations/batch.js +64 -6
  28. package/build/services/escalations/client.d.ts +4 -2
  29. package/build/services/escalations/client.js +4 -2
  30. package/build/services/escalations/fold.d.ts +3 -2
  31. package/build/services/escalations/fold.js +13 -2
  32. package/build/services/escalations/index.d.ts +1 -1
  33. package/build/services/escalations/index.js +2 -1
  34. package/build/services/hotmesh/index.js +17 -4
  35. package/build/services/quorum/index.js +13 -13
  36. package/build/services/router/consumption/index.d.ts +20 -0
  37. package/build/services/router/consumption/index.js +177 -7
  38. package/build/services/store/providers/postgres/kvtransaction.js +8 -1
  39. package/build/services/store/providers/postgres/postgres.d.ts +2 -1
  40. package/build/services/store/providers/postgres/postgres.js +18 -9
  41. package/build/services/stream/index.d.ts +16 -0
  42. package/build/services/stream/index.js +23 -0
  43. package/build/services/stream/providers/postgres/messages.d.ts +7 -0
  44. package/build/services/stream/providers/postgres/messages.js +27 -1
  45. package/build/services/stream/providers/postgres/notifications.d.ts +13 -0
  46. package/build/services/stream/providers/postgres/notifications.js +89 -2
  47. package/build/services/stream/providers/postgres/postgres.d.ts +7 -0
  48. package/build/services/stream/providers/postgres/postgres.js +24 -3
  49. package/build/services/stream/providers/postgres/scout.d.ts +10 -0
  50. package/build/services/stream/providers/postgres/scout.js +38 -4
  51. package/build/services/stream/registry.d.ts +6 -0
  52. package/build/services/stream/registry.js +11 -2
  53. package/build/services/sub/providers/postgres/postgres.d.ts +6 -0
  54. package/build/services/sub/providers/postgres/postgres.js +62 -2
  55. package/build/services/task/index.js +1 -1
  56. package/build/services/worker/credentials.js +5 -0
  57. package/build/services/worker/index.js +5 -5
  58. package/build/types/hmsh_escalations.d.ts +32 -0
  59. package/build/types/hmsh_escalations.js +5 -1
  60. package/build/types/index.d.ts +3 -3
  61. package/build/types/index.js +2 -1
  62. package/build/types/postgres.d.ts +20 -0
  63. package/build/types/provider.d.ts +28 -0
  64. package/index.ts +2 -0
  65. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ESCALATION_TRIGGER_KEY = exports.ESCALATION_ACCUMULATED_KEY = exports.ESCALATION_ACCUMULATE_CONFIG_KEY = exports.ESCALATION_ACCUMULATE_ITEMS_KEY = exports.ESCALATION_ACCUMULATE_KEYS_KEY = exports.ESCALATION_ACCUMULATE_MAX_KEY = exports.ESCALATION_ACCUMULATE_COUNT_KEY = exports.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = exports.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY = exports.ESCALATION_BATCH_FILLED_AT_KEY = exports.ESCALATION_BATCH_ITEMS_KEY = exports.ESCALATION_BATCH_KEYS_KEY = exports.ESCALATION_BATCH_COUNT_KEY = exports.ESCALATION_BATCH_PENDING_KEY = exports.ValueType = exports.trace = exports.SpanKind = exports.SpanStatusCode = exports.propagation = exports.metrics = exports.context = exports.StreamStatus = exports.StreamRole = exports.StreamDataType = exports.KeyType = exports.HookGate = exports.CollationFaultType = void 0;
3
+ exports.ESCALATION_TRIGGER_KEY = exports.ESCALATION_ACCUMULATED_KEY = exports.ESCALATION_ACCUMULATE_CONFIG_KEY = exports.ESCALATION_ACCUMULATE_ITEMS_KEY = exports.ESCALATION_ACCUMULATE_KEYS_KEY = exports.ESCALATION_ACCUMULATE_MAX_KEY = exports.ESCALATION_ACCUMULATE_COUNT_KEY = exports.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = exports.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY = exports.ESCALATION_BATCH_FILLED_BY_KEY = exports.ESCALATION_BATCH_FILLED_AT_KEY = exports.ESCALATION_BATCH_ITEMS_KEY = exports.ESCALATION_BATCH_KEYS_KEY = exports.ESCALATION_BATCH_COUNT_KEY = exports.ESCALATION_BATCH_PENDING_KEY = exports.ValueType = exports.trace = exports.SpanKind = exports.SpanStatusCode = exports.propagation = exports.metrics = exports.context = exports.StreamStatus = exports.StreamRole = exports.StreamDataType = exports.KeyType = exports.HookGate = exports.CollationFaultType = void 0;
4
4
  var collator_1 = require("./collator");
5
5
  Object.defineProperty(exports, "CollationFaultType", { enumerable: true, get: function () { return collator_1.CollationFaultType; } });
6
6
  var hook_1 = require("./hook");
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "ESCALATION_BATCH_COUNT_KEY", { enumerable: true,
25
25
  Object.defineProperty(exports, "ESCALATION_BATCH_KEYS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_KEYS_KEY; } });
26
26
  Object.defineProperty(exports, "ESCALATION_BATCH_ITEMS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY; } });
27
27
  Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_AT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FILLED_AT_KEY; } });
28
+ Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_BY_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FILLED_BY_KEY; } });
28
29
  Object.defineProperty(exports, "ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY; } });
29
30
  Object.defineProperty(exports, "ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH; } });
30
31
  Object.defineProperty(exports, "ESCALATION_ACCUMULATE_COUNT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_ACCUMULATE_COUNT_KEY; } });
@@ -8,6 +8,14 @@ export interface PostgresClientOptions {
8
8
  max?: number;
9
9
  idleTimeoutMillis?: number;
10
10
  ssl?: boolean | Record<string, unknown>;
11
+ /** Milliseconds to wait for a connection before failing (pg default: forever). */
12
+ connectionTimeoutMillis?: number;
13
+ /** Enable TCP keepalive on the socket. */
14
+ keepAlive?: boolean;
15
+ /** Idle time before the first TCP keepalive probe. */
16
+ keepAliveInitialDelayMillis?: number;
17
+ /** Reported in `pg_stat_activity.application_name`. */
18
+ application_name?: string;
11
19
  }
12
20
  export type PostgresJobEnumType = 'status' | 'jdata' | 'adata' | 'udata' | 'jmark' | 'hmark' | 'other';
13
21
  export type PostgresClassType = {
@@ -30,6 +38,18 @@ export interface PostgresClientType {
30
38
  off?: (event: 'notification', listener: (notification: PostgresNotification) => void) => void;
31
39
  removeAllListeners?: (event?: string) => void;
32
40
  }
41
+ /**
42
+ * Payload of the `'reconnected'` event a resilient client emits after it
43
+ * replaces a lost session. Session state (LISTEN channels, open
44
+ * transactions) does not survive; owners re-arm it on this event.
45
+ */
46
+ export interface PostgresReconnectedEvent {
47
+ connectionId: string;
48
+ generation: number;
49
+ at: number;
50
+ downtimeMs: number;
51
+ attempts: number;
52
+ }
33
53
  export interface PostgresPoolClientType {
34
54
  connect: () => Promise<PostgresClientType>;
35
55
  release: () => void;
@@ -139,3 +139,31 @@ export interface KVSQLProviderTransaction extends ProviderTransaction {
139
139
  scan(cursor: number, count?: number): ProviderTransaction;
140
140
  rename(oldKey: string, newKey: string): ProviderTransaction;
141
141
  }
142
+ export type ConnectionHealthEvent = 'lost' | 'restored';
143
+ /** A HotMesh database connection lost its session and began reconnecting. */
144
+ export interface ConnectionLostEvent {
145
+ connectionId: string;
146
+ /** Epoch milliseconds when the loss was observed. */
147
+ at: number;
148
+ error: {
149
+ message: string;
150
+ code?: string;
151
+ };
152
+ }
153
+ /** A HotMesh database connection replaced its lost session. */
154
+ export interface ConnectionRestoredEvent {
155
+ connectionId: string;
156
+ /** Epoch milliseconds when the new session was established. */
157
+ at: number;
158
+ downtimeMs: number;
159
+ attempts: number;
160
+ }
161
+ /** Process-wide availability of HotMesh's resilient database connections. */
162
+ export interface ConnectionHealthSnapshot {
163
+ /** `down` while any registered connection is reconnecting. */
164
+ state: 'up' | 'down';
165
+ total: number;
166
+ down: number;
167
+ /** Epoch milliseconds of the earliest loss still unrecovered. */
168
+ downSince?: number;
169
+ }
package/index.ts CHANGED
@@ -18,6 +18,7 @@ import * as KeyStore from './modules/key';
18
18
  import { ConnectorService as Connector } from './services/connector/factory';
19
19
  import { PostgresConnection as ConnectorPostgres } from './services/connector/providers/postgres';
20
20
  import { NatsConnection as ConnectorNATS } from './services/connector/providers/nats';
21
+ import { ConnectionHealth } from './services/connector/health';
21
22
  import { Escalations } from './services/escalations';
22
23
 
23
24
  export {
@@ -25,6 +26,7 @@ export {
25
26
  Connector, //factory
26
27
  ConnectorNATS,
27
28
  ConnectorPostgres,
29
+ ConnectionHealth,
28
30
 
29
31
  //Top-level Modules
30
32
  HotMesh,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.29.1",
3
+ "version": "0.31.0",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",