@hotmeshio/hotmesh 0.12.1 → 0.14.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.
- package/README.md +18 -22
- package/build/modules/enums.d.ts +60 -5
- package/build/modules/enums.js +62 -7
- package/build/modules/errors.d.ts +15 -2
- package/build/modules/errors.js +17 -1
- package/build/modules/storage.d.ts +1 -0
- package/build/modules/storage.js +2 -1
- package/build/package.json +8 -2
- package/build/services/activities/activity/context.d.ts +22 -0
- package/build/services/activities/activity/context.js +76 -0
- package/build/services/activities/activity/index.d.ts +116 -0
- package/build/services/activities/activity/index.js +299 -0
- package/build/services/activities/activity/mapping.d.ts +12 -0
- package/build/services/activities/activity/mapping.js +63 -0
- package/build/services/activities/activity/process.d.ts +28 -0
- package/build/services/activities/activity/process.js +100 -0
- package/build/services/activities/activity/protocol.d.ts +39 -0
- package/build/services/activities/activity/protocol.js +151 -0
- package/build/services/activities/activity/state.d.ts +40 -0
- package/build/services/activities/activity/state.js +143 -0
- package/build/services/activities/activity/transition.d.ts +23 -0
- package/build/services/activities/activity/transition.js +71 -0
- package/build/services/activities/activity/verify.d.ts +22 -0
- package/build/services/activities/activity/verify.js +85 -0
- package/build/services/activities/await.d.ts +1 -4
- package/build/services/activities/await.js +2 -36
- package/build/services/activities/cycle.d.ts +1 -11
- package/build/services/activities/cycle.js +3 -46
- package/build/services/activities/hook.d.ts +2 -11
- package/build/services/activities/hook.js +30 -50
- package/build/services/activities/interrupt.d.ts +2 -4
- package/build/services/activities/interrupt.js +4 -38
- package/build/services/activities/signal.d.ts +1 -11
- package/build/services/activities/signal.js +3 -48
- package/build/services/activities/trigger.d.ts +1 -3
- package/build/services/activities/trigger.js +0 -3
- package/build/services/activities/worker.d.ts +3 -6
- package/build/services/activities/worker.js +4 -40
- package/build/services/connector/factory.d.ts +6 -0
- package/build/services/connector/factory.js +24 -0
- package/build/services/dba/index.d.ts +14 -4
- package/build/services/dba/index.js +57 -18
- package/build/services/durable/activity.d.ts +30 -0
- package/build/services/durable/activity.js +46 -0
- package/build/services/durable/client.d.ts +26 -31
- package/build/services/durable/client.js +26 -31
- package/build/services/durable/connection.d.ts +13 -7
- package/build/services/durable/connection.js +13 -7
- package/build/services/durable/exporter.d.ts +2 -2
- package/build/services/durable/exporter.js +27 -12
- package/build/services/durable/handle.d.ts +59 -41
- package/build/services/durable/handle.js +61 -41
- package/build/services/durable/index.d.ts +152 -283
- package/build/services/durable/index.js +161 -289
- package/build/services/durable/interceptor.d.ts +43 -33
- package/build/services/durable/interceptor.js +59 -39
- package/build/services/durable/schemas/factory.d.ts +2 -3
- package/build/services/durable/schemas/factory.js +180 -30
- package/build/services/durable/telemetry.d.ts +80 -0
- package/build/services/durable/telemetry.js +137 -0
- package/build/services/durable/worker.d.ts +100 -21
- package/build/services/durable/worker.js +314 -60
- package/build/services/durable/workflow/all.d.ts +1 -1
- package/build/services/durable/workflow/all.js +1 -1
- package/build/services/durable/workflow/cancellationScope.d.ts +104 -0
- package/build/services/durable/workflow/cancellationScope.js +139 -0
- package/build/services/durable/workflow/common.d.ts +5 -4
- package/build/services/durable/workflow/common.js +6 -1
- package/build/services/durable/workflow/{waitFor.d.ts → condition.d.ts} +9 -8
- package/build/services/durable/workflow/{waitFor.js → condition.js} +44 -11
- package/build/services/durable/workflow/continueAsNew.d.ts +65 -0
- package/build/services/durable/workflow/continueAsNew.js +92 -0
- package/build/services/durable/workflow/didRun.d.ts +2 -2
- package/build/services/durable/workflow/didRun.js +4 -4
- package/build/services/durable/workflow/enrich.d.ts +5 -0
- package/build/services/durable/workflow/enrich.js +5 -0
- package/build/services/durable/workflow/entityMethods.d.ts +7 -0
- package/build/services/durable/workflow/entityMethods.js +7 -0
- package/build/services/durable/workflow/execHook.js +3 -3
- package/build/services/durable/workflow/execHookBatch.js +2 -2
- package/build/services/durable/workflow/{execChild.d.ts → executeChild.d.ts} +4 -40
- package/build/services/durable/workflow/{execChild.js → executeChild.js} +36 -45
- package/build/services/durable/workflow/hook.d.ts +1 -1
- package/build/services/durable/workflow/hook.js +4 -3
- package/build/services/durable/workflow/index.d.ts +45 -50
- package/build/services/durable/workflow/index.js +46 -51
- package/build/services/durable/workflow/interruption.d.ts +7 -6
- package/build/services/durable/workflow/interruption.js +11 -7
- package/build/services/durable/workflow/patched.d.ts +72 -0
- package/build/services/durable/workflow/patched.js +110 -0
- package/build/services/durable/workflow/proxyActivities.d.ts +7 -7
- package/build/services/durable/workflow/proxyActivities.js +51 -15
- package/build/services/durable/workflow/searchMethods.d.ts +7 -0
- package/build/services/durable/workflow/searchMethods.js +7 -0
- package/build/services/durable/workflow/signal.d.ts +4 -4
- package/build/services/durable/workflow/signal.js +4 -4
- package/build/services/durable/workflow/{sleepFor.d.ts → sleep.d.ts} +7 -7
- package/build/services/durable/workflow/{sleepFor.js → sleep.js} +39 -10
- package/build/services/durable/workflow/terminate.d.ts +55 -0
- package/build/services/durable/workflow/{interrupt.js → terminate.js} +21 -21
- package/build/services/durable/workflow/trace.js +2 -2
- package/build/services/durable/workflow/uuid4.d.ts +14 -0
- package/build/services/durable/workflow/uuid4.js +39 -0
- package/build/services/durable/workflow/{context.d.ts → workflowInfo.d.ts} +5 -5
- package/build/services/durable/workflow/{context.js → workflowInfo.js} +7 -7
- package/build/services/engine/compiler.d.ts +19 -0
- package/build/services/engine/compiler.js +20 -0
- package/build/services/engine/completion.d.ts +46 -0
- package/build/services/engine/completion.js +145 -0
- package/build/services/engine/dispatch.d.ts +24 -0
- package/build/services/engine/dispatch.js +98 -0
- package/build/services/engine/index.d.ts +49 -81
- package/build/services/engine/index.js +175 -573
- package/build/services/engine/init.d.ts +42 -0
- package/build/services/engine/init.js +74 -0
- package/build/services/engine/pubsub.d.ts +50 -0
- package/build/services/engine/pubsub.js +118 -0
- package/build/services/engine/reporting.d.ts +20 -0
- package/build/services/engine/reporting.js +38 -0
- package/build/services/engine/schema.d.ts +23 -0
- package/build/services/engine/schema.js +62 -0
- package/build/services/engine/signal.d.ts +57 -0
- package/build/services/engine/signal.js +117 -0
- package/build/services/engine/state.d.ts +35 -0
- package/build/services/engine/state.js +61 -0
- package/build/services/engine/version.d.ts +31 -0
- package/build/services/engine/version.js +73 -0
- package/build/services/hotmesh/deployment.d.ts +21 -0
- package/build/services/hotmesh/deployment.js +25 -0
- package/build/services/hotmesh/index.d.ts +142 -533
- package/build/services/hotmesh/index.js +223 -674
- package/build/services/hotmesh/init.d.ts +42 -0
- package/build/services/hotmesh/init.js +93 -0
- package/build/services/hotmesh/jobs.d.ts +67 -0
- package/build/services/hotmesh/jobs.js +99 -0
- package/build/services/hotmesh/pubsub.d.ts +38 -0
- package/build/services/hotmesh/pubsub.js +54 -0
- package/build/services/hotmesh/quorum.d.ts +30 -0
- package/build/services/hotmesh/quorum.js +62 -0
- package/build/services/hotmesh/validation.d.ts +6 -0
- package/build/services/hotmesh/validation.js +28 -0
- package/build/services/quorum/index.js +1 -0
- package/build/services/router/consumption/index.d.ts +11 -5
- package/build/services/router/consumption/index.js +24 -17
- package/build/services/router/error-handling/index.d.ts +2 -2
- package/build/services/router/error-handling/index.js +14 -14
- package/build/services/router/index.d.ts +1 -1
- package/build/services/router/index.js +2 -2
- package/build/services/serializer/index.d.ts +22 -0
- package/build/services/serializer/index.js +39 -1
- package/build/services/store/index.d.ts +1 -0
- package/build/services/store/providers/postgres/exporter-sql.d.ts +2 -2
- package/build/services/store/providers/postgres/exporter-sql.js +4 -4
- package/build/services/store/providers/postgres/kvtables.js +7 -6
- package/build/services/store/providers/postgres/kvtypes/hash/basic.js +67 -52
- package/build/services/store/providers/postgres/kvtypes/hash/jsonb.js +87 -72
- package/build/services/store/providers/postgres/kvtypes/hash/udata.js +106 -79
- package/build/services/store/providers/postgres/kvtypes/hash/utils.d.ts +16 -0
- package/build/services/store/providers/postgres/kvtypes/hash/utils.js +29 -16
- package/build/services/store/providers/postgres/postgres.d.ts +1 -0
- package/build/services/store/providers/postgres/postgres.js +14 -4
- package/build/services/stream/factory.d.ts +3 -1
- package/build/services/stream/factory.js +2 -2
- package/build/services/stream/index.d.ts +1 -0
- package/build/services/stream/providers/nats/nats.d.ts +1 -0
- package/build/services/stream/providers/nats/nats.js +1 -0
- package/build/services/stream/providers/postgres/credentials.d.ts +56 -0
- package/build/services/stream/providers/postgres/credentials.js +129 -0
- package/build/services/stream/providers/postgres/kvtables.js +18 -0
- package/build/services/stream/providers/postgres/messages.js +7 -7
- package/build/services/stream/providers/postgres/notifications.js +16 -2
- package/build/services/stream/providers/postgres/postgres.d.ts +7 -0
- package/build/services/stream/providers/postgres/postgres.js +35 -4
- package/build/services/stream/providers/postgres/procedures.d.ts +21 -0
- package/build/services/stream/providers/postgres/procedures.js +213 -0
- package/build/services/stream/providers/postgres/secured.d.ts +34 -0
- package/build/services/stream/providers/postgres/secured.js +146 -0
- package/build/services/stream/providers/postgres/stats.d.ts +1 -0
- package/build/services/stream/providers/postgres/stats.js +1 -0
- package/build/services/stream/registry.d.ts +1 -1
- package/build/services/stream/registry.js +5 -2
- package/build/services/telemetry/index.d.ts +10 -1
- package/build/services/telemetry/index.js +40 -7
- package/build/services/worker/credentials.d.ts +51 -0
- package/build/services/worker/credentials.js +87 -0
- package/build/services/worker/index.d.ts +2 -2
- package/build/services/worker/index.js +7 -6
- package/build/types/codec.d.ts +84 -0
- package/build/types/codec.js +2 -0
- package/build/types/dba.d.ts +39 -3
- package/build/types/durable.d.ts +123 -25
- package/build/types/error.d.ts +10 -0
- package/build/types/exporter.d.ts +1 -1
- package/build/types/hotmesh.d.ts +67 -4
- package/build/types/index.d.ts +2 -1
- package/build/types/provider.d.ts +2 -2
- package/build/types/quorum.d.ts +35 -1
- package/build/types/stream.d.ts +12 -6
- package/package.json +8 -2
- package/build/services/activities/activity.d.ts +0 -192
- package/build/services/activities/activity.js +0 -786
- package/build/services/durable/workflow/interrupt.d.ts +0 -55
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine bootstrap — channel setup, router creation, config validation.
|
|
3
|
+
*
|
|
4
|
+
* Called once during `EngineService.init()` to wire the engine to its
|
|
5
|
+
* backing store, stream, search, and subscription transports.
|
|
6
|
+
*/
|
|
7
|
+
import { ExporterService } from '../exporter';
|
|
8
|
+
import { Router } from '../router';
|
|
9
|
+
import { TaskService } from '../task';
|
|
10
|
+
import { ILogger } from '../logger';
|
|
11
|
+
import { SearchService } from '../search';
|
|
12
|
+
import { StoreService } from '../store';
|
|
13
|
+
import { StreamService } from '../stream';
|
|
14
|
+
import { SubService } from '../sub';
|
|
15
|
+
import { HotMeshConfig, HotMeshSettings } from '../../types/hotmesh';
|
|
16
|
+
import { ProviderClient, ProviderTransaction } from '../../types/provider';
|
|
17
|
+
import { StreamDataResponse } from '../../types/stream';
|
|
18
|
+
interface InitContext {
|
|
19
|
+
namespace: string;
|
|
20
|
+
appId: string;
|
|
21
|
+
guid: string;
|
|
22
|
+
logger: ILogger;
|
|
23
|
+
search: SearchService<ProviderClient> | null;
|
|
24
|
+
store: StoreService<ProviderClient, ProviderTransaction> | null;
|
|
25
|
+
stream: StreamService<ProviderClient, ProviderTransaction> | null;
|
|
26
|
+
subscribe: SubService<ProviderClient> | null;
|
|
27
|
+
router: Router<typeof this.stream> | null;
|
|
28
|
+
taskService: TaskService | null;
|
|
29
|
+
exporter: ExporterService | null;
|
|
30
|
+
inited: string;
|
|
31
|
+
processStreamMessage(streamData: StreamDataResponse): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export declare function verifyEngineFields(config: HotMeshConfig): void;
|
|
34
|
+
export declare function initSearchChannel(instance: InitContext, search: ProviderClient, store?: ProviderClient): Promise<void>;
|
|
35
|
+
export declare function initStoreChannel(instance: InitContext, store: ProviderClient): Promise<void>;
|
|
36
|
+
export declare function initSubChannel(instance: InitContext, sub: ProviderClient, store: ProviderClient): Promise<void>;
|
|
37
|
+
export declare function initStreamChannel(instance: InitContext, stream: ProviderClient, store: ProviderClient): Promise<void>;
|
|
38
|
+
export declare function initRouter(instance: InitContext, config: HotMeshConfig): Promise<Router<StreamService<ProviderClient, ProviderTransaction>>>;
|
|
39
|
+
export declare function registerStreamConsumer(instance: InitContext, config: HotMeshConfig): Promise<void>;
|
|
40
|
+
export declare function initServices(instance: InitContext): void;
|
|
41
|
+
export declare function getSettings(instance: InitContext): Promise<HotMeshSettings>;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Engine bootstrap — channel setup, router creation, config validation.
|
|
4
|
+
*
|
|
5
|
+
* Called once during `EngineService.init()` to wire the engine to its
|
|
6
|
+
* backing store, stream, search, and subscription transports.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getSettings = exports.initServices = exports.registerStreamConsumer = exports.initRouter = exports.initStreamChannel = exports.initSubChannel = exports.initStoreChannel = exports.initSearchChannel = exports.verifyEngineFields = void 0;
|
|
10
|
+
const utils_1 = require("../../modules/utils");
|
|
11
|
+
const registry_1 = require("../stream/registry");
|
|
12
|
+
const exporter_1 = require("../exporter");
|
|
13
|
+
const router_1 = require("../router");
|
|
14
|
+
const factory_1 = require("../search/factory");
|
|
15
|
+
const factory_2 = require("../store/factory");
|
|
16
|
+
const factory_3 = require("../stream/factory");
|
|
17
|
+
const factory_4 = require("../sub/factory");
|
|
18
|
+
const task_1 = require("../task");
|
|
19
|
+
const stream_1 = require("../../types/stream");
|
|
20
|
+
function verifyEngineFields(config) {
|
|
21
|
+
if (!(0, utils_1.identifyProvider)(config.engine.store) ||
|
|
22
|
+
!(0, utils_1.identifyProvider)(config.engine.stream) ||
|
|
23
|
+
!(0, utils_1.identifyProvider)(config.engine.sub)) {
|
|
24
|
+
throw new Error('engine must include `store`, `stream`, and `sub` fields.');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.verifyEngineFields = verifyEngineFields;
|
|
28
|
+
async function initSearchChannel(instance, search, store) {
|
|
29
|
+
instance.search = await factory_1.SearchServiceFactory.init(search, store, instance.namespace, instance.appId, instance.logger);
|
|
30
|
+
}
|
|
31
|
+
exports.initSearchChannel = initSearchChannel;
|
|
32
|
+
async function initStoreChannel(instance, store) {
|
|
33
|
+
instance.store = await factory_2.StoreServiceFactory.init(store, instance.namespace, instance.appId, instance.logger);
|
|
34
|
+
}
|
|
35
|
+
exports.initStoreChannel = initStoreChannel;
|
|
36
|
+
async function initSubChannel(instance, sub, store) {
|
|
37
|
+
instance.subscribe = await factory_4.SubServiceFactory.init(sub, store, instance.namespace, instance.appId, instance.guid, instance.logger);
|
|
38
|
+
}
|
|
39
|
+
exports.initSubChannel = initSubChannel;
|
|
40
|
+
async function initStreamChannel(instance, stream, store) {
|
|
41
|
+
instance.stream = await factory_3.StreamServiceFactory.init(stream, store, instance.namespace, instance.appId, instance.logger);
|
|
42
|
+
}
|
|
43
|
+
exports.initStreamChannel = initStreamChannel;
|
|
44
|
+
async function initRouter(instance, config) {
|
|
45
|
+
const throttle = await instance.store.getThrottleRate(':');
|
|
46
|
+
return new router_1.Router({
|
|
47
|
+
namespace: instance.namespace,
|
|
48
|
+
appId: instance.appId,
|
|
49
|
+
guid: instance.guid,
|
|
50
|
+
role: stream_1.StreamRole.ENGINE,
|
|
51
|
+
reclaimDelay: config.engine.reclaimDelay,
|
|
52
|
+
reclaimCount: config.engine.reclaimCount,
|
|
53
|
+
throttle,
|
|
54
|
+
readonly: config.engine.readonly,
|
|
55
|
+
}, instance.stream, instance.logger);
|
|
56
|
+
}
|
|
57
|
+
exports.initRouter = initRouter;
|
|
58
|
+
async function registerStreamConsumer(instance, config) {
|
|
59
|
+
await registry_1.StreamConsumerRegistry.registerEngine(instance.namespace, instance.appId, instance.guid, instance.processStreamMessage.bind(instance), instance.stream, instance.store, instance.logger, {
|
|
60
|
+
reclaimDelay: config.engine.reclaimDelay,
|
|
61
|
+
reclaimCount: config.engine.reclaimCount,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.registerStreamConsumer = registerStreamConsumer;
|
|
65
|
+
function initServices(instance) {
|
|
66
|
+
instance.taskService = new task_1.TaskService(instance.store, instance.logger);
|
|
67
|
+
instance.exporter = new exporter_1.ExporterService(instance.appId, instance.store, instance.logger);
|
|
68
|
+
instance.inited = (0, utils_1.formatISODate)(new Date());
|
|
69
|
+
}
|
|
70
|
+
exports.initServices = initServices;
|
|
71
|
+
async function getSettings(instance) {
|
|
72
|
+
return await instance.store.getSettings();
|
|
73
|
+
}
|
|
74
|
+
exports.getSettings = getSettings;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pub/sub messaging, subscriptions, and one-time callbacks.
|
|
3
|
+
*
|
|
4
|
+
* This module handles the full publish/subscribe lifecycle:
|
|
5
|
+
* - `pub()` → fire-and-forget job trigger
|
|
6
|
+
* - `pubsub()` → trigger + await result (with timeout)
|
|
7
|
+
* - `sub()/unsub()` → permanent topic subscriptions
|
|
8
|
+
* - `psub()/punsub()` → pattern-based subscriptions
|
|
9
|
+
* - `add()` → raw stream message publish
|
|
10
|
+
*/
|
|
11
|
+
import { Router } from '../router';
|
|
12
|
+
import { StoreService } from '../store';
|
|
13
|
+
import { StreamService } from '../stream';
|
|
14
|
+
import { SubService } from '../sub';
|
|
15
|
+
import { ILogger } from '../logger';
|
|
16
|
+
import { AppVID } from '../../types/app';
|
|
17
|
+
import { ExtensionType, JobData, JobOutput, JobState } from '../../types/job';
|
|
18
|
+
import { ProviderClient, ProviderTransaction } from '../../types/provider';
|
|
19
|
+
import { JobMessageCallback } from '../../types/quorum';
|
|
20
|
+
import { StreamData, StreamDataResponse } from '../../types/stream';
|
|
21
|
+
interface PubSubContext {
|
|
22
|
+
guid: string;
|
|
23
|
+
appId: string;
|
|
24
|
+
store: StoreService<ProviderClient, ProviderTransaction>;
|
|
25
|
+
stream: StreamService<ProviderClient, ProviderTransaction>;
|
|
26
|
+
subscribe: SubService<ProviderClient>;
|
|
27
|
+
router: Router<typeof this.stream> | null;
|
|
28
|
+
logger: ILogger;
|
|
29
|
+
jobCallbacks: Record<string, JobMessageCallback>;
|
|
30
|
+
getVID(vid?: AppVID): Promise<AppVID>;
|
|
31
|
+
initActivity(topic: string, data?: JobData, context?: JobState): Promise<any>;
|
|
32
|
+
getState(topic: string, jobId: string): Promise<JobOutput>;
|
|
33
|
+
getPublishesTopic(context: JobState): Promise<string>;
|
|
34
|
+
}
|
|
35
|
+
export declare function pub(instance: PubSubContext, topic: string, data: JobData, context?: JobState, extended?: ExtensionType): Promise<string>;
|
|
36
|
+
export declare function sub(instance: PubSubContext, topic: string, callback: JobMessageCallback): Promise<void>;
|
|
37
|
+
export declare function unsub(instance: PubSubContext, topic: string): Promise<void>;
|
|
38
|
+
export declare function psub(instance: PubSubContext, wild: string, callback: JobMessageCallback): Promise<void>;
|
|
39
|
+
export declare function punsub(instance: PubSubContext, wild: string): Promise<void>;
|
|
40
|
+
export declare function pubsub(instance: PubSubContext, topic: string, data: JobData, context?: JobState | null, timeout?: number): Promise<JobOutput>;
|
|
41
|
+
export declare function add(instance: PubSubContext, streamData: StreamData | StreamDataResponse): Promise<string>;
|
|
42
|
+
export declare function registerJobCallback(instance: PubSubContext, jobId: string, jobCallback: JobMessageCallback): void;
|
|
43
|
+
export declare function removeJobCallback(instance: PubSubContext, jobId: string): void;
|
|
44
|
+
export declare function hasOneTimeSubscription(context: JobState): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Resolves the `publishes` topic for the activity that produced
|
|
47
|
+
* this job's output — used to notify permanent subscribers.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getPublishesTopic(instance: PubSubContext, context: JobState): Promise<string>;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pub/sub messaging, subscriptions, and one-time callbacks.
|
|
4
|
+
*
|
|
5
|
+
* This module handles the full publish/subscribe lifecycle:
|
|
6
|
+
* - `pub()` → fire-and-forget job trigger
|
|
7
|
+
* - `pubsub()` → trigger + await result (with timeout)
|
|
8
|
+
* - `sub()/unsub()` → permanent topic subscriptions
|
|
9
|
+
* - `psub()/punsub()` → pattern-based subscriptions
|
|
10
|
+
* - `add()` → raw stream message publish
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.getPublishesTopic = exports.hasOneTimeSubscription = exports.removeJobCallback = exports.registerJobCallback = exports.add = exports.pubsub = exports.punsub = exports.psub = exports.unsub = exports.sub = exports.pub = void 0;
|
|
14
|
+
const enums_1 = require("../../modules/enums");
|
|
15
|
+
const key_1 = require("../../modules/key");
|
|
16
|
+
async function pub(instance, topic, data, context, extended) {
|
|
17
|
+
const activityHandler = await instance.initActivity(topic, data, context);
|
|
18
|
+
if (activityHandler) {
|
|
19
|
+
return await activityHandler.process(extended);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
throw new Error(`unable to process activity for topic ${topic}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.pub = pub;
|
|
26
|
+
async function sub(instance, topic, callback) {
|
|
27
|
+
const subscriptionCallback = createSubscriptionCallback(instance, callback);
|
|
28
|
+
return await instance.subscribe.subscribe(key_1.KeyType.QUORUM, subscriptionCallback, instance.appId, topic);
|
|
29
|
+
}
|
|
30
|
+
exports.sub = sub;
|
|
31
|
+
async function unsub(instance, topic) {
|
|
32
|
+
return await instance.subscribe.unsubscribe(key_1.KeyType.QUORUM, instance.appId, topic);
|
|
33
|
+
}
|
|
34
|
+
exports.unsub = unsub;
|
|
35
|
+
async function psub(instance, wild, callback) {
|
|
36
|
+
const subscriptionCallback = createSubscriptionCallback(instance, callback);
|
|
37
|
+
return await instance.subscribe.psubscribe(key_1.KeyType.QUORUM, subscriptionCallback, instance.appId, wild);
|
|
38
|
+
}
|
|
39
|
+
exports.psub = psub;
|
|
40
|
+
async function punsub(instance, wild) {
|
|
41
|
+
return await instance.subscribe.punsubscribe(key_1.KeyType.QUORUM, instance.appId, wild);
|
|
42
|
+
}
|
|
43
|
+
exports.punsub = punsub;
|
|
44
|
+
async function pubsub(instance, topic, data, context, timeout = enums_1.HMSH_OTT_WAIT_TIME) {
|
|
45
|
+
context = {
|
|
46
|
+
metadata: {
|
|
47
|
+
ngn: instance.guid,
|
|
48
|
+
trc: context?.metadata?.trc,
|
|
49
|
+
spn: context?.metadata?.spn,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
const jobId = await pub(instance, topic, data, context);
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
registerJobCallback(instance, jobId, (topic, output) => {
|
|
55
|
+
if (output.metadata.err) {
|
|
56
|
+
const error = JSON.parse(output.metadata.err);
|
|
57
|
+
reject({
|
|
58
|
+
error,
|
|
59
|
+
job_id: output.metadata.jid,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
resolve(output);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
removeJobCallback(instance, jobId);
|
|
68
|
+
reject({
|
|
69
|
+
code: enums_1.HMSH_CODE_TIMEOUT,
|
|
70
|
+
message: 'timeout',
|
|
71
|
+
job_id: jobId,
|
|
72
|
+
});
|
|
73
|
+
}, timeout);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.pubsub = pubsub;
|
|
77
|
+
async function add(instance, streamData) {
|
|
78
|
+
return (await instance.router?.publishMessage(null, streamData));
|
|
79
|
+
}
|
|
80
|
+
exports.add = add;
|
|
81
|
+
function registerJobCallback(instance, jobId, jobCallback) {
|
|
82
|
+
instance.jobCallbacks[jobId] = jobCallback;
|
|
83
|
+
}
|
|
84
|
+
exports.registerJobCallback = registerJobCallback;
|
|
85
|
+
function removeJobCallback(instance, jobId) {
|
|
86
|
+
delete instance.jobCallbacks[jobId];
|
|
87
|
+
}
|
|
88
|
+
exports.removeJobCallback = removeJobCallback;
|
|
89
|
+
function hasOneTimeSubscription(context) {
|
|
90
|
+
return Boolean(context.metadata.ngn);
|
|
91
|
+
}
|
|
92
|
+
exports.hasOneTimeSubscription = hasOneTimeSubscription;
|
|
93
|
+
/**
|
|
94
|
+
* Resolves the `publishes` topic for the activity that produced
|
|
95
|
+
* this job's output — used to notify permanent subscribers.
|
|
96
|
+
*/
|
|
97
|
+
async function getPublishesTopic(instance, context) {
|
|
98
|
+
const config = await instance.getVID();
|
|
99
|
+
const activityId = context.metadata.aid || context['$self']?.output?.metadata?.aid;
|
|
100
|
+
const schema = await instance.store.getSchema(activityId, config);
|
|
101
|
+
return schema.publishes;
|
|
102
|
+
}
|
|
103
|
+
exports.getPublishesTopic = getPublishesTopic;
|
|
104
|
+
// ── helpers ────────────────────────────────────────────────────────
|
|
105
|
+
/**
|
|
106
|
+
* Wraps a user-provided callback to handle reference-based payloads.
|
|
107
|
+
* When `_ref` is true the published message was too large, so
|
|
108
|
+
* we fetch the full job state before invoking the callback.
|
|
109
|
+
*/
|
|
110
|
+
function createSubscriptionCallback(instance, callback) {
|
|
111
|
+
return async (topic, message) => {
|
|
112
|
+
let jobOutput = message.job;
|
|
113
|
+
if (message._ref && message.job?.metadata) {
|
|
114
|
+
jobOutput = await instance.getState(message.job.metadata.tpc, message.job.metadata.jid);
|
|
115
|
+
}
|
|
116
|
+
callback(message.topic, jobOutput);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stats queries and job-ID lookups.
|
|
3
|
+
*
|
|
4
|
+
* Builds a `GetStatsOptions` query by instantiating a Trigger activity
|
|
5
|
+
* to resolve the job key and granularity, then delegates to
|
|
6
|
+
* ReporterService for the actual data retrieval.
|
|
7
|
+
*/
|
|
8
|
+
import { AppVID } from '../../types/app';
|
|
9
|
+
import { JobData } from '../../types/job';
|
|
10
|
+
import { GetStatsOptions, IdsResponse, JobStatsInput, StatsResponse } from '../../types/stats';
|
|
11
|
+
interface ReportingContext {
|
|
12
|
+
getVID(vid?: AppVID): Promise<AppVID>;
|
|
13
|
+
initActivity(topic: string, data?: JobData): Promise<any>;
|
|
14
|
+
store: any;
|
|
15
|
+
logger: any;
|
|
16
|
+
}
|
|
17
|
+
export declare function getStats(instance: ReportingContext, topic: string, query: JobStatsInput): Promise<StatsResponse>;
|
|
18
|
+
export declare function getIds(instance: ReportingContext, topic: string, query: JobStatsInput, queryFacets?: string[]): Promise<IdsResponse>;
|
|
19
|
+
export declare function resolveQuery(instance: ReportingContext, topic: string, query: JobStatsInput): Promise<GetStatsOptions>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Stats queries and job-ID lookups.
|
|
4
|
+
*
|
|
5
|
+
* Builds a `GetStatsOptions` query by instantiating a Trigger activity
|
|
6
|
+
* to resolve the job key and granularity, then delegates to
|
|
7
|
+
* ReporterService for the actual data retrieval.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.resolveQuery = exports.getIds = exports.getStats = void 0;
|
|
11
|
+
const reporter_1 = require("../reporter");
|
|
12
|
+
async function getStats(instance, topic, query) {
|
|
13
|
+
const vid = await instance.getVID();
|
|
14
|
+
const reporter = new reporter_1.ReporterService(vid, instance.store, instance.logger);
|
|
15
|
+
const resolvedQuery = await resolveQuery(instance, topic, query);
|
|
16
|
+
return await reporter.getStats(resolvedQuery);
|
|
17
|
+
}
|
|
18
|
+
exports.getStats = getStats;
|
|
19
|
+
async function getIds(instance, topic, query, queryFacets = []) {
|
|
20
|
+
const vid = await instance.getVID();
|
|
21
|
+
const reporter = new reporter_1.ReporterService(vid, instance.store, instance.logger);
|
|
22
|
+
const resolvedQuery = await resolveQuery(instance, topic, query);
|
|
23
|
+
return await reporter.getIds(resolvedQuery, queryFacets);
|
|
24
|
+
}
|
|
25
|
+
exports.getIds = getIds;
|
|
26
|
+
async function resolveQuery(instance, topic, query) {
|
|
27
|
+
const trigger = (await instance.initActivity(topic, query.data));
|
|
28
|
+
await trigger.getState();
|
|
29
|
+
return {
|
|
30
|
+
end: query.end,
|
|
31
|
+
start: query.start,
|
|
32
|
+
range: query.range,
|
|
33
|
+
granularity: trigger.resolveGranularity(),
|
|
34
|
+
key: trigger.resolveJobKey(trigger.createInputContext()),
|
|
35
|
+
sparse: query.sparse,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.resolveQuery = resolveQuery;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity schema lookup and handler instantiation.
|
|
3
|
+
*
|
|
4
|
+
* Every stream message targets an activity node in the compiled DAG.
|
|
5
|
+
* This module resolves the activity's schema (from the store) and
|
|
6
|
+
* creates the correct handler subclass (Trigger, Worker, Hook, …).
|
|
7
|
+
*/
|
|
8
|
+
import { StoreService } from '../store';
|
|
9
|
+
import { ILogger } from '../logger';
|
|
10
|
+
import { AppVID } from '../../types/app';
|
|
11
|
+
import { ActivityType } from '../../types/activity';
|
|
12
|
+
import { JobState, JobData } from '../../types/job';
|
|
13
|
+
import { ProviderClient, ProviderTransaction } from '../../types/provider';
|
|
14
|
+
interface SchemaContext {
|
|
15
|
+
appId: string;
|
|
16
|
+
store: StoreService<ProviderClient, ProviderTransaction>;
|
|
17
|
+
logger: ILogger;
|
|
18
|
+
getVID(vid?: AppVID): Promise<AppVID>;
|
|
19
|
+
}
|
|
20
|
+
export declare function initActivity(instance: SchemaContext, topic: string, data?: JobData, context?: JobState): Promise<any>;
|
|
21
|
+
export declare function getSchema(instance: SchemaContext, topic: string): Promise<[activityId: string, schema: ActivityType]>;
|
|
22
|
+
export declare function isPrivate(topic: string): boolean;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Activity schema lookup and handler instantiation.
|
|
4
|
+
*
|
|
5
|
+
* Every stream message targets an activity node in the compiled DAG.
|
|
6
|
+
* This module resolves the activity's schema (from the store) and
|
|
7
|
+
* creates the correct handler subclass (Trigger, Worker, Hook, …).
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.isPrivate = exports.getSchema = exports.initActivity = void 0;
|
|
14
|
+
const utils_1 = require("../../modules/utils");
|
|
15
|
+
const activities_1 = __importDefault(require("../activities"));
|
|
16
|
+
async function initActivity(instance, topic, data = {}, context) {
|
|
17
|
+
const [activityId, schema] = await getSchema(instance, topic);
|
|
18
|
+
if (!schema) {
|
|
19
|
+
throw new Error(`Activity schema not found for "${activityId}" (topic: ${topic}) in app ${instance.appId}`);
|
|
20
|
+
}
|
|
21
|
+
const ActivityHandler = activities_1.default[schema.type];
|
|
22
|
+
if (ActivityHandler) {
|
|
23
|
+
const utc = (0, utils_1.formatISODate)(new Date());
|
|
24
|
+
const metadata = {
|
|
25
|
+
aid: activityId,
|
|
26
|
+
atp: schema.type,
|
|
27
|
+
stp: schema.subtype,
|
|
28
|
+
ac: utc,
|
|
29
|
+
au: utc,
|
|
30
|
+
};
|
|
31
|
+
const hook = null;
|
|
32
|
+
return new ActivityHandler(schema, data, metadata, hook, instance, context);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new Error(`activity type ${schema.type} not found`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.initActivity = initActivity;
|
|
39
|
+
async function getSchema(instance, topic) {
|
|
40
|
+
const app = (await instance.store.getApp(instance.appId));
|
|
41
|
+
if (!app) {
|
|
42
|
+
throw new Error(`no app found for id ${instance.appId}`);
|
|
43
|
+
}
|
|
44
|
+
if (isPrivate(topic)) {
|
|
45
|
+
const activityId = topic.substring(1);
|
|
46
|
+
const schema = await instance.store.getSchema(activityId, await instance.getVID(app));
|
|
47
|
+
return [activityId, schema];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const activityId = await instance.store.getSubscription(topic, await instance.getVID(app));
|
|
51
|
+
if (activityId) {
|
|
52
|
+
const schema = await instance.store.getSchema(activityId, await instance.getVID(app));
|
|
53
|
+
return [activityId, schema];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`no subscription found for topic ${topic} in app ${instance.appId} for app version ${app.version}`);
|
|
57
|
+
}
|
|
58
|
+
exports.getSchema = getSchema;
|
|
59
|
+
function isPrivate(topic) {
|
|
60
|
+
return topic.startsWith('.');
|
|
61
|
+
}
|
|
62
|
+
exports.isPrivate = isPrivate;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signal delivery to paused hook activities.
|
|
3
|
+
*
|
|
4
|
+
* Signals resume workflows waiting on external events:
|
|
5
|
+
* - `signal()` → single webhook delivery to a specific hook
|
|
6
|
+
* - `signalAll()` → fan-out to all workflows matching a query
|
|
7
|
+
* - `hookTime()` → time-based hook awaken (sleep/cron)
|
|
8
|
+
*
|
|
9
|
+
* Also provides the quorum-level task processors for web/time hooks
|
|
10
|
+
* and the router throttle control.
|
|
11
|
+
*/
|
|
12
|
+
import { Router } from '../router';
|
|
13
|
+
import { StoreService } from '../store';
|
|
14
|
+
import { StreamService } from '../stream';
|
|
15
|
+
import { SubService } from '../sub';
|
|
16
|
+
import { TaskService } from '../task';
|
|
17
|
+
import { ILogger } from '../logger';
|
|
18
|
+
import { AppVID } from '../../types/app';
|
|
19
|
+
import { JobData } from '../../types/job';
|
|
20
|
+
import { ProviderClient, ProviderTransaction } from '../../types/provider';
|
|
21
|
+
import { JobStatsInput } from '../../types/stats';
|
|
22
|
+
import { StreamCode, StreamStatus } from '../../types/stream';
|
|
23
|
+
import { WorkListTaskType } from '../../types/task';
|
|
24
|
+
import { HookInterface } from '../../types/hook';
|
|
25
|
+
import { JobMessageCallback } from '../../types/quorum';
|
|
26
|
+
import { JobOutput } from '../../types/job';
|
|
27
|
+
interface SignalContext {
|
|
28
|
+
guid: string;
|
|
29
|
+
appId: string;
|
|
30
|
+
store: StoreService<ProviderClient, ProviderTransaction>;
|
|
31
|
+
stream: StreamService<ProviderClient, ProviderTransaction>;
|
|
32
|
+
subscribe: SubService<ProviderClient>;
|
|
33
|
+
router: Router<typeof this.stream> | null;
|
|
34
|
+
taskService: TaskService;
|
|
35
|
+
logger: ILogger;
|
|
36
|
+
jobCallbacks: Record<string, JobMessageCallback>;
|
|
37
|
+
getVID(vid?: AppVID): Promise<AppVID>;
|
|
38
|
+
getSchema(topic: string): Promise<[string, any]>;
|
|
39
|
+
resolveQuery(topic: string, query: JobStatsInput): Promise<any>;
|
|
40
|
+
interrupt(topic: string, jobId: string, options?: any): Promise<string>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Delivers a signal (data payload) to a paused hook activity,
|
|
44
|
+
* resuming its Leg 2 execution.
|
|
45
|
+
*/
|
|
46
|
+
export declare function signal(instance: SignalContext, topic: string, data: JobData, status?: StreamStatus, code?: StreamCode, transaction?: ProviderTransaction): Promise<string>;
|
|
47
|
+
export declare function hookTime(instance: SignalContext, jobId: string, gId: string, topicOrActivity: string, type?: WorkListTaskType): Promise<string | void>;
|
|
48
|
+
/**
|
|
49
|
+
* Fan-out variant that delivers data to all paused workflows
|
|
50
|
+
* matching a search query.
|
|
51
|
+
*/
|
|
52
|
+
export declare function signalAll(instance: SignalContext, hookTopic: string, data: JobData, keyResolver: JobStatsInput, queryFacets?: string[]): Promise<string[]>;
|
|
53
|
+
export declare function processWebHooks(instance: SignalContext, signalFn: HookInterface): Promise<void>;
|
|
54
|
+
export declare function processTimeHooks(instance: SignalContext, hookTimeFn: (jobId: string, gId: string, activityId: string, type: WorkListTaskType) => Promise<void>): Promise<void>;
|
|
55
|
+
export declare function throttle(instance: SignalContext, delayInMillis: number): Promise<void>;
|
|
56
|
+
export declare function routeToSubscribers(instance: SignalContext, topic: string, message: JobOutput): void;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Signal delivery to paused hook activities.
|
|
4
|
+
*
|
|
5
|
+
* Signals resume workflows waiting on external events:
|
|
6
|
+
* - `signal()` → single webhook delivery to a specific hook
|
|
7
|
+
* - `signalAll()` → fan-out to all workflows matching a query
|
|
8
|
+
* - `hookTime()` → time-based hook awaken (sleep/cron)
|
|
9
|
+
*
|
|
10
|
+
* Also provides the quorum-level task processors for web/time hooks
|
|
11
|
+
* and the router throttle control.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.routeToSubscribers = exports.throttle = exports.processTimeHooks = exports.processWebHooks = exports.signalAll = exports.hookTime = exports.signal = void 0;
|
|
15
|
+
const key_1 = require("../../modules/key");
|
|
16
|
+
const utils_1 = require("../../modules/utils");
|
|
17
|
+
const reporter_1 = require("../reporter");
|
|
18
|
+
const task_1 = require("../task");
|
|
19
|
+
const stream_1 = require("../../types/stream");
|
|
20
|
+
/**
|
|
21
|
+
* Delivers a signal (data payload) to a paused hook activity,
|
|
22
|
+
* resuming its Leg 2 execution.
|
|
23
|
+
*/
|
|
24
|
+
async function signal(instance, topic, data, status = stream_1.StreamStatus.SUCCESS, code = 200, transaction) {
|
|
25
|
+
const hookRule = await instance.taskService.getHookRule(topic);
|
|
26
|
+
const [aid] = await instance.getSchema(`.${hookRule.to}`);
|
|
27
|
+
const streamData = {
|
|
28
|
+
type: stream_1.StreamDataType.WEBHOOK,
|
|
29
|
+
status,
|
|
30
|
+
code,
|
|
31
|
+
metadata: {
|
|
32
|
+
guid: (0, utils_1.guid)(),
|
|
33
|
+
aid,
|
|
34
|
+
topic,
|
|
35
|
+
},
|
|
36
|
+
data,
|
|
37
|
+
};
|
|
38
|
+
return (await instance.router?.publishMessage(null, streamData, transaction));
|
|
39
|
+
}
|
|
40
|
+
exports.signal = signal;
|
|
41
|
+
async function hookTime(instance, jobId, gId, topicOrActivity, type) {
|
|
42
|
+
if (type === 'interrupt' || type === 'expire') {
|
|
43
|
+
return await instance.interrupt(topicOrActivity, jobId, {
|
|
44
|
+
suppress: true,
|
|
45
|
+
expire: 1,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const [aid, ...dimensions] = topicOrActivity.split(',');
|
|
49
|
+
const dad = `,${dimensions.join(',')}`;
|
|
50
|
+
const streamData = {
|
|
51
|
+
type: stream_1.StreamDataType.TIMEHOOK,
|
|
52
|
+
metadata: {
|
|
53
|
+
guid: (0, utils_1.guid)(),
|
|
54
|
+
jid: jobId,
|
|
55
|
+
gid: gId,
|
|
56
|
+
dad,
|
|
57
|
+
aid,
|
|
58
|
+
},
|
|
59
|
+
data: { timestamp: Date.now() },
|
|
60
|
+
};
|
|
61
|
+
await instance.router?.publishMessage(null, streamData);
|
|
62
|
+
}
|
|
63
|
+
exports.hookTime = hookTime;
|
|
64
|
+
/**
|
|
65
|
+
* Fan-out variant that delivers data to all paused workflows
|
|
66
|
+
* matching a search query.
|
|
67
|
+
*/
|
|
68
|
+
async function signalAll(instance, hookTopic, data, keyResolver, queryFacets = []) {
|
|
69
|
+
const config = await instance.getVID();
|
|
70
|
+
const hookRule = await instance.taskService.getHookRule(hookTopic);
|
|
71
|
+
if (hookRule) {
|
|
72
|
+
const subscriptionTopic = await (0, utils_1.getSubscriptionTopic)(hookRule.to, instance.store, config);
|
|
73
|
+
const resolvedQuery = await instance.resolveQuery(subscriptionTopic, keyResolver);
|
|
74
|
+
const reporter = new reporter_1.ReporterService(config, instance.store, instance.logger);
|
|
75
|
+
const workItems = await reporter.getWorkItems(resolvedQuery, queryFacets);
|
|
76
|
+
if (workItems.length) {
|
|
77
|
+
const taskService = new task_1.TaskService(instance.store, instance.logger);
|
|
78
|
+
await taskService.enqueueWorkItems(workItems.map((workItem) => [
|
|
79
|
+
hookTopic,
|
|
80
|
+
workItem,
|
|
81
|
+
keyResolver.scrub || false,
|
|
82
|
+
JSON.stringify(data),
|
|
83
|
+
].join(key_1.VALSEP)));
|
|
84
|
+
instance.subscribe.publish(key_1.KeyType.QUORUM, { type: 'work', originator: instance.guid }, instance.appId);
|
|
85
|
+
}
|
|
86
|
+
return workItems;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new Error(`unable to find hook rule for topic ${hookTopic}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.signalAll = signalAll;
|
|
93
|
+
async function processWebHooks(instance, signalFn) {
|
|
94
|
+
instance.taskService.processWebHooks(signalFn);
|
|
95
|
+
}
|
|
96
|
+
exports.processWebHooks = processWebHooks;
|
|
97
|
+
async function processTimeHooks(instance, hookTimeFn) {
|
|
98
|
+
instance.taskService.processTimeHooks(hookTimeFn);
|
|
99
|
+
}
|
|
100
|
+
exports.processTimeHooks = processTimeHooks;
|
|
101
|
+
async function throttle(instance, delayInMillis) {
|
|
102
|
+
try {
|
|
103
|
+
instance.router?.setThrottle(delayInMillis);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
instance.logger.error('engine-throttle-error', { error: e });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.throttle = throttle;
|
|
110
|
+
function routeToSubscribers(instance, topic, message) {
|
|
111
|
+
const jobCallback = instance.jobCallbacks[message.metadata.jid];
|
|
112
|
+
if (jobCallback) {
|
|
113
|
+
delete instance.jobCallbacks[message.metadata.jid];
|
|
114
|
+
jobCallback(topic, message);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.routeToSubscribers = routeToSubscribers;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Job state retrieval, export, and symbol compression.
|
|
3
|
+
*
|
|
4
|
+
* Provides read access to job data at various granularities:
|
|
5
|
+
* - `getState()` → full hydrated job tree
|
|
6
|
+
* - `getQueryState()` → specific fields only
|
|
7
|
+
* - `getRaw()` → raw hash data (no hydration)
|
|
8
|
+
* - `getStatus()` → job status code only
|
|
9
|
+
* - `export()` → full export via ExporterService
|
|
10
|
+
*/
|
|
11
|
+
import { ExporterService } from '../exporter';
|
|
12
|
+
import { StoreService } from '../store';
|
|
13
|
+
import { ILogger } from '../logger';
|
|
14
|
+
import { AppVID } from '../../types/app';
|
|
15
|
+
import { ExportOptions, JobExport } from '../../types/exporter';
|
|
16
|
+
import { JobOutput, JobStatus } from '../../types/job';
|
|
17
|
+
import { ProviderClient, ProviderTransaction } from '../../types/provider';
|
|
18
|
+
import { StringAnyType, StringStringType } from '../../types/serializer';
|
|
19
|
+
interface StateContext {
|
|
20
|
+
appId: string;
|
|
21
|
+
store: StoreService<ProviderClient, ProviderTransaction>;
|
|
22
|
+
exporter: ExporterService;
|
|
23
|
+
logger: ILogger;
|
|
24
|
+
getVID(vid?: AppVID): Promise<AppVID>;
|
|
25
|
+
}
|
|
26
|
+
export declare function exportJob(instance: StateContext, jobId: string, options?: ExportOptions): Promise<JobExport>;
|
|
27
|
+
export declare function getRaw(instance: StateContext, jobId: string): Promise<StringStringType>;
|
|
28
|
+
export declare function getStatus(instance: StateContext, jobId: string): Promise<JobStatus>;
|
|
29
|
+
export declare function getState(instance: StateContext, topic: string, jobId: string): Promise<JobOutput>;
|
|
30
|
+
export declare function getQueryState(instance: StateContext, jobId: string, fields: string[]): Promise<StringAnyType>;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated
|
|
33
|
+
*/
|
|
34
|
+
export declare function compress(instance: StateContext, terms: string[]): Promise<boolean>;
|
|
35
|
+
export {};
|