@nightx.co/pulsar 0.0.0-stage → 1.0.15
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 +14 -2
- package/dist/chunk-3sg08kqp.js +10 -0
- package/dist/chunk-3sg08kqp.js.map +9 -0
- package/dist/chunk-a9kye38b.js +54 -0
- package/dist/chunk-a9kye38b.js.map +12 -0
- package/dist/chunk-cpn1qh4e.js +10 -0
- package/dist/chunk-cpn1qh4e.js.map +12 -0
- package/dist/chunk-rrj8rm04.js +10 -0
- package/dist/chunk-rrj8rm04.js.map +11 -0
- package/dist/cluster/Nebula.d.ts +30 -0
- package/dist/cluster/Nebula.d.ts.map +1 -0
- package/dist/helpers/computeConfigDelta.d.ts +18 -0
- package/dist/helpers/computeConfigDelta.d.ts.map +1 -0
- package/dist/helpers/defineQueue.d.ts +13 -0
- package/dist/helpers/defineQueue.d.ts.map +1 -0
- package/dist/helpers/generateShaHash.d.ts +2 -0
- package/dist/helpers/generateShaHash.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +50 -0
- package/dist/integrations/PulsarEventsIntegrations.d.ts +7 -0
- package/dist/integrations/PulsarEventsIntegrations.d.ts.map +1 -0
- package/dist/integrations/PulsarLoggerIntegrations.d.ts +12 -0
- package/dist/integrations/PulsarLoggerIntegrations.d.ts.map +1 -0
- package/dist/integrations/index.d.ts +4 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +8 -0
- package/dist/integrations/index.js.map +11 -0
- package/dist/modules/Queue.module.d.ts +45 -0
- package/dist/modules/Queue.module.d.ts.map +1 -0
- package/dist/modules/Scheduler.module.d.ts +42 -0
- package/dist/modules/Scheduler.module.d.ts.map +1 -0
- package/dist/modules/Tick.module.d.ts +35 -0
- package/dist/modules/Tick.module.d.ts.map +1 -0
- package/dist/modules/TickController.module.d.ts +36 -0
- package/dist/modules/TickController.module.d.ts.map +1 -0
- package/dist/monitoring/PulsarMonitoringStreamProducer.d.ts +2 -0
- package/dist/monitoring/PulsarMonitoringStreamProducer.d.ts.map +1 -0
- package/dist/monitoring/index.d.ts +2 -0
- package/dist/monitoring/index.d.ts.map +1 -0
- package/dist/monitoring/server/PulsarMonitoringStream.d.ts +2 -0
- package/dist/monitoring/server/PulsarMonitoringStream.d.ts.map +1 -0
- package/dist/network/NetworkInterface.d.ts +13 -0
- package/dist/network/NetworkInterface.d.ts.map +1 -0
- package/dist/network/UnifiedTransportManager.d.ts +21 -0
- package/dist/network/UnifiedTransportManager.d.ts.map +1 -0
- package/dist/network/abstract/BaseNetworkDriver.d.ts +17 -0
- package/dist/network/abstract/BaseNetworkDriver.d.ts.map +1 -0
- package/dist/network/auth/Authenticator.d.ts +2 -0
- package/dist/network/auth/Authenticator.d.ts.map +1 -0
- package/dist/network/drivers/HttpNetworkDriver.d.ts +31 -0
- package/dist/network/drivers/HttpNetworkDriver.d.ts.map +1 -0
- package/dist/network/drivers/WebSocketNetworkDriver.d.ts +23 -0
- package/dist/network/drivers/WebSocketNetworkDriver.d.ts.map +1 -0
- package/dist/network/helpers/httpQueueOperations.d.ts +2 -0
- package/dist/network/helpers/httpQueueOperations.d.ts.map +1 -0
- package/dist/network/interfaces/network.types.d.ts +13 -0
- package/dist/network/interfaces/network.types.d.ts.map +1 -0
- package/dist/run/Queues.d.ts +2 -0
- package/dist/run/Queues.d.ts.map +1 -0
- package/dist/run/index.d.ts +2 -0
- package/dist/run/index.d.ts.map +1 -0
- package/dist/run/index2.d.ts +2 -0
- package/dist/run/index2.d.ts.map +1 -0
- package/dist/runtimes/IsolateRuntime.d.ts +17 -0
- package/dist/runtimes/IsolateRuntime.d.ts.map +1 -0
- package/dist/runtimes/PersistentRuntime.d.ts +22 -0
- package/dist/runtimes/PersistentRuntime.d.ts.map +1 -0
- package/dist/runtimes/ServerlessRuntime.d.ts +15 -0
- package/dist/runtimes/ServerlessRuntime.d.ts.map +1 -0
- package/dist/runtimes/runtimeTypes.d.ts +15 -0
- package/dist/runtimes/runtimeTypes.d.ts.map +1 -0
- package/dist/server/PulsarRequestHandler.d.ts +41 -0
- package/dist/server/PulsarRequestHandler.d.ts.map +1 -0
- package/dist/server/helpers/acquireRedisLock.d.ts +14 -0
- package/dist/server/helpers/acquireRedisLock.d.ts.map +1 -0
- package/dist/server/helpers/checkFencingValidity.d.ts +14 -0
- package/dist/server/helpers/checkFencingValidity.d.ts.map +1 -0
- package/dist/server/helpers/performIsolateRestart.d.ts +20 -0
- package/dist/server/helpers/performIsolateRestart.d.ts.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +8 -0
- package/dist/server/index.js.map +13 -0
- package/dist/server/parser/parseRequest.d.ts +10 -0
- package/dist/server/parser/parseRequest.d.ts.map +1 -0
- package/dist/server/utility/extract-headers.d.ts +14 -0
- package/dist/server/utility/extract-headers.d.ts.map +1 -0
- package/dist/service/ConfigurationStore.d.ts +23 -0
- package/dist/service/ConfigurationStore.d.ts.map +1 -0
- package/dist/service/Isolate.service.d.ts +12 -0
- package/dist/service/Isolate.service.d.ts.map +1 -0
- package/dist/service/Pulsar.service.d.ts +41 -0
- package/dist/service/Pulsar.service.d.ts.map +1 -0
- package/dist/service/PulsarBaseService.d.ts +49 -0
- package/dist/service/PulsarBaseService.d.ts.map +1 -0
- package/dist/service/PulsarEventBus.d.ts +36 -0
- package/dist/service/PulsarEventBus.d.ts.map +1 -0
- package/dist/service/SwarmBudgetTracker.d.ts +14 -0
- package/dist/service/SwarmBudgetTracker.d.ts.map +1 -0
- package/dist/service/consumers/PulsarWorker.d.ts +10 -0
- package/dist/service/consumers/PulsarWorker.d.ts.map +1 -0
- package/dist/shared/PulsarRuntimeCore.d.ts +55 -0
- package/dist/shared/PulsarRuntimeCore.d.ts.map +1 -0
- package/dist/static/TimingProfile.d.ts +9 -0
- package/dist/static/TimingProfile.d.ts.map +1 -0
- package/dist/static/static.d.ts +3 -0
- package/dist/static/static.d.ts.map +1 -0
- package/dist/storage/PulsarStorage.d.ts +42 -0
- package/dist/storage/PulsarStorage.d.ts.map +1 -0
- package/dist/storage/drivers/PostgresDriver.d.ts +20 -0
- package/dist/storage/drivers/PostgresDriver.d.ts.map +1 -0
- package/dist/storage/drivers/RedisDriver.d.ts +20 -0
- package/dist/storage/drivers/RedisDriver.d.ts.map +1 -0
- package/dist/storage/drivers/types.d.ts +27 -0
- package/dist/storage/drivers/types.d.ts.map +1 -0
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +403 -0
- package/dist/storage/index.js.map +21 -0
- package/dist/storage/repositories/PostgresEngineOperationRepository.d.ts +39 -0
- package/dist/storage/repositories/PostgresEngineOperationRepository.d.ts.map +1 -0
- package/dist/storage/repositories/PostgresQueueRepository.d.ts +26 -0
- package/dist/storage/repositories/PostgresQueueRepository.d.ts.map +1 -0
- package/dist/storage/repositories/QueueRepository.d.ts +20 -0
- package/dist/storage/repositories/QueueRepository.d.ts.map +1 -0
- package/dist/storage/repositories/RedisQueueRepository.d.ts +28 -0
- package/dist/storage/repositories/RedisQueueRepository.d.ts.map +1 -0
- package/dist/subsys/DeferredTickEvaluator.d.ts +23 -0
- package/dist/subsys/DeferredTickEvaluator.d.ts.map +1 -0
- package/dist/subsys/EventBus.d.ts +13 -0
- package/dist/subsys/EventBus.d.ts.map +1 -0
- package/dist/subsys/ExecutionProfileSwitcher.d.ts +10 -0
- package/dist/subsys/ExecutionProfileSwitcher.d.ts.map +1 -0
- package/dist/subsys/LoggerService.d.ts +15 -0
- package/dist/subsys/LoggerService.d.ts.map +1 -0
- package/dist/subsys/PulsarClock.d.ts +32 -0
- package/dist/subsys/PulsarClock.d.ts.map +1 -0
- package/dist/subsys/RuntimeCacheStorage.d.ts +18 -0
- package/dist/subsys/RuntimeCacheStorage.d.ts.map +1 -0
- package/dist/subsys/RuntimeEventBridge.d.ts +16 -0
- package/dist/subsys/RuntimeEventBridge.d.ts.map +1 -0
- package/dist/types/base.types.d.ts +65 -0
- package/dist/types/base.types.d.ts.map +1 -0
- package/dist/types/config.types.d.ts +56 -0
- package/dist/types/config.types.d.ts.map +1 -0
- package/dist/types/consumer.types.d.ts +36 -0
- package/dist/types/consumer.types.d.ts.map +1 -0
- package/dist/types/engine.types.d.ts +139 -0
- package/dist/types/engine.types.d.ts.map +1 -0
- package/dist/types/eventTriggerStrategry.types.d.ts +34 -0
- package/dist/types/eventTriggerStrategry.types.d.ts.map +1 -0
- package/dist/types/integrations.types.d.ts +16 -0
- package/dist/types/integrations.types.d.ts.map +1 -0
- package/dist/types/nebula.types.d.ts +65 -0
- package/dist/types/nebula.types.d.ts.map +1 -0
- package/dist/types/queue.types.d.ts +106 -0
- package/dist/types/queue.types.d.ts.map +1 -0
- package/dist/types/runtime.types.d.ts +89 -0
- package/dist/types/runtime.types.d.ts.map +1 -0
- package/package.json +71 -5
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PostgresDriver } from "../drivers/PostgresDriver.d.ts";
|
|
2
|
+
import type { EngineQueuesConfig } from "../../types/queue.types.d.ts";
|
|
3
|
+
import type { IConfigurationObject, IConfigSyncResult } from "../../types/config.types.d.ts";
|
|
4
|
+
export interface IPulsarPostgresEngineOperationRepository {
|
|
5
|
+
addRestart(queues: EngineQueuesConfig[]): Promise<void>;
|
|
6
|
+
deleteRestart(queue: string): Promise<void>;
|
|
7
|
+
checkFencingTokenValidity(queue: string, token: string | number): Promise<boolean>;
|
|
8
|
+
verifyAndSyncConfiguration(host: string, instanceId: string, url: string, configurations: IConfigurationObject): Promise<IConfigSyncResult>;
|
|
9
|
+
subscribeToDatabaseEvents<T extends unknown>(channel: string, onEvent: (event: T) => Promise<void>, onListen?: () => void): Promise<void>;
|
|
10
|
+
getPollingQueueEntries(queueName: string, limit: number): Promise<Array<IPoolQueueEntry>>;
|
|
11
|
+
deletePollingQueueEntry(id: number): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface IPoolQueueEntry {
|
|
14
|
+
id: number;
|
|
15
|
+
queue: string;
|
|
16
|
+
payload: {
|
|
17
|
+
queue_name: string;
|
|
18
|
+
fencing_token: number;
|
|
19
|
+
execution_at: string;
|
|
20
|
+
};
|
|
21
|
+
created_at: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class PostgresEngineOperationRepository implements IPulsarPostgresEngineOperationRepository {
|
|
24
|
+
private driver;
|
|
25
|
+
private readonly logger;
|
|
26
|
+
constructor(driver: PostgresDriver);
|
|
27
|
+
private get sql();
|
|
28
|
+
addRestart(queues: EngineQueuesConfig[]): Promise<void>;
|
|
29
|
+
updateRestartOwnership(queue: string | null | undefined, owner: string): Promise<void>;
|
|
30
|
+
deleteRestart(queue: string | '__GLOBAL__'): Promise<void>;
|
|
31
|
+
pingHealthCheck(): Promise<void>;
|
|
32
|
+
checkFencingTokenValidity(queue: string, token: string | number): Promise<boolean>;
|
|
33
|
+
verifyAndSyncConfiguration(host: 'PULSAR_STANDALONE' | 'NEBULA_CLUSTER', instanceId: string, url: string, configurations: IConfigurationObject): Promise<IConfigSyncResult>;
|
|
34
|
+
private synchronizeQueueTriggers;
|
|
35
|
+
subscribeToDatabaseEvents<T extends unknown>(channel: string, onEvent: (event: T) => Promise<void>, onListen?: () => void): Promise<void>;
|
|
36
|
+
getPollingQueueEntries(queueName: string, limit?: number): Promise<Array<IPoolQueueEntry>>;
|
|
37
|
+
deletePollingQueueEntry(id: number): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=PostgresEngineOperationRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresEngineOperationRepository.d.ts","sourceRoot":"","sources":["../../../src/storage/repositories/PostgresEngineOperationRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,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CAAC,MAAM;IAF1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;gBAEd,MAAM,EAAG,cAAc;IAI3C,OAAO,KAAK,GAAG,GAEd;IAEK,UAAU,CAAC,MAAM,EAAG,kBAAkB,EAAE;IAiCxC,sBAAsB,CAAC,KAAK,EAAG,MAAM,GAAG,IAAI,YAAO,EAAE,KAAK,EAAG,MAAM;IAYnE,aAAa,CAAC,KAAK,EAAG,MAAM,GAAG,YAAY;IAO3C,eAAe;IAUf,yBAAyB,CAAC,KAAK,EAAG,MAAM,EAAE,KAAK,EAAG,MAAM,GAAG,MAAM;IAmBjE,0BAA0B,CAAE,IAAI,EAAG,mBAAmB,GAAG,gBAAgB,EAAE,UAAU,EAAG,MAAM,EAAE,GAAG,EAAG,MAAM,EAAE,cAAc,EAAG,oBAAoB,GAAI,OAAO,CAAC,iBAAiB,CAAC;YAkDzK,wBAAwB;IAgDhC,yBAAyB,CAAC,CAAC,SAAS,OAAO,EAAE,OAAO,EAAG,MAAM,EAAE,OAAO,EAAG,CAAC,KAAK,EAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI;IAY5H,sBAAsB,CAAC,SAAS,EAAG,MAAM,EAAE,KAAK,GAAG,MAAW,GAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAajG,uBAAuB,CAAC,EAAE,EAAG,MAAM,GAAI,OAAO,CAAC,IAAI,CAAC;CAM7D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PostgresDriver } from "../drivers/PostgresDriver.d.ts";
|
|
2
|
+
import type { IBatchCandidate } from "../../modules/Tick.module.d.ts";
|
|
3
|
+
import { BaseQueueRepository } from "./QueueRepository.d.ts";
|
|
4
|
+
export declare class PostgresQueueRepository extends BaseQueueRepository {
|
|
5
|
+
private readonly driver;
|
|
6
|
+
constructor(driver: PostgresDriver);
|
|
7
|
+
private get sql();
|
|
8
|
+
private get prefix();
|
|
9
|
+
registerWorker(queue: string, candidateBatches: IBatchCandidate[], concurrency: number, globalMaxConcurrency?: number): Promise<string[]>;
|
|
10
|
+
deregisterWorker(workerId: string, queue: string): Promise<void>;
|
|
11
|
+
getActiveWorkersCount(queue: string): Promise<number>;
|
|
12
|
+
setFutureSchedule(queue: string, scheduleAt: string): Promise<void>;
|
|
13
|
+
getGlobalActiveWorkersCount(): Promise<number>;
|
|
14
|
+
refundGlobalJobBudget(amount: number, window: string): Promise<void>;
|
|
15
|
+
private budgetKeyPrefix;
|
|
16
|
+
claimGlobalJobBudget(requested: number, maxGlobalJobsPerTick: number): Promise<{
|
|
17
|
+
granted: number;
|
|
18
|
+
window: string;
|
|
19
|
+
}>;
|
|
20
|
+
acquireQueueLock(lockKey: string, ownerId: string, ttlMs: number): Promise<boolean>;
|
|
21
|
+
releaseQueueLock(lockKey: string, ownerId: string): Promise<boolean>;
|
|
22
|
+
evaluateDeadRun(queueName: string, poolerType: "interval-driven-pooler" | "event-driven-pooler", totalJobs: number, continuationOwnerId: string, dispatchTtlMs?: number, idpLockKey?: string, edpLockPrefix?: string): Promise<boolean>;
|
|
23
|
+
clearDispatchPending(lockKey: string): Promise<void>;
|
|
24
|
+
getStopSignal(): Promise<boolean>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=PostgresQueueRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresQueueRepository.d.ts","sourceRoot":"","sources":["../../../src/storage/repositories/PostgresQueueRepository.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAM3D,qBAAa,uBAAwB,SAAQ,mBAAmB;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAG,cAAc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
|
3
|
+
abstract getActiveWorkersCount(queue: string): Promise<number>;
|
|
4
|
+
abstract getGlobalActiveWorkersCount(): Promise<number>;
|
|
5
|
+
abstract registerWorker(queue: string, candidateBatches: IBatchCandidate[], concurrency: number, globalMaxConcurrency: number): Promise<string[]>;
|
|
6
|
+
abstract deregisterWorker(workerId: string, queue: string): Promise<void>;
|
|
7
|
+
abstract claimGlobalJobBudget(requested: number, maxGlobalJobsPerTick: number): Promise<{
|
|
8
|
+
granted: number;
|
|
9
|
+
window: string;
|
|
10
|
+
}>;
|
|
11
|
+
abstract refundGlobalJobBudget(amount: number, window: string): Promise<void>;
|
|
12
|
+
abstract acquireQueueLock(lockKey: string, ownerId: string, ttlMs: number): Promise<boolean>;
|
|
13
|
+
abstract releaseQueueLock(lockKey: string, ownerId: string): Promise<boolean>;
|
|
14
|
+
abstract evaluateDeadRun(queueName: string, poolerType: "interval-driven-pooler" | "event-driven-pooler", totalJobs: number, continuationOwnerId: string, dispatchTtlMs: number, idpLockKey?: string, edpLockPrefix?: string): Promise<boolean>;
|
|
15
|
+
abstract clearDispatchPending(lockKey: string): Promise<void>;
|
|
16
|
+
abstract setFutureSchedule(queue: string, scheduleAt: string): Promise<void>;
|
|
17
|
+
abstract getStopSignal(queue: string): Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
export type IQueueRepository = BaseQueueRepository;
|
|
20
|
+
//# sourceMappingURL=QueueRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueRepository.d.ts","sourceRoot":"","sources":["../../../src/storage/repositories/QueueRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,8BAAsB,mBAAmB;aACrB,qBAAqB,CAAC,KAAK,EAAG,MAAM,GAAI,OAAO,CAAC,MAAM,CAAC;aACvD,2BAA2B,IAAM,OAAO,CAAC,MAAM,CAAC;aAEhD,cAAc,CAAC,KAAK,EAAG,MA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
|
|
|
1
|
+
import type { RedisDriver } from "../drivers/RedisDriver.d.ts";
|
|
2
|
+
import type { IBatchCandidate } from "../../modules/Tick.module.d.ts";
|
|
3
|
+
import { BaseQueueRepository } from "./QueueRepository.d.ts";
|
|
4
|
+
export declare class RedisQueueRepository extends BaseQueueRepository {
|
|
5
|
+
private readonly driver;
|
|
6
|
+
private protocol;
|
|
7
|
+
constructor(driver: RedisDriver);
|
|
8
|
+
private get redis();
|
|
9
|
+
private get prefix();
|
|
10
|
+
registerWorker(queue: string, candidateBatches: IBatchCandidate[], concurrency: number, globalMaxConcurrency?: number): Promise<string[]>;
|
|
11
|
+
deregisterWorker(workerId: string, queue: string): Promise<void>;
|
|
12
|
+
getActiveWorkersCount(queue: string): Promise<number>;
|
|
13
|
+
getGlobalActiveWorkersCount(): Promise<number>;
|
|
14
|
+
setFutureSchedule(queue: string, scheduleAt: string): Promise<void>;
|
|
15
|
+
private budgetKeyPrefix;
|
|
16
|
+
claimGlobalJobBudget(requested: number, maxGlobalJobsPerTick: number): Promise<{
|
|
17
|
+
granted: number;
|
|
18
|
+
window: string;
|
|
19
|
+
}>;
|
|
20
|
+
refundGlobalJobBudget(amount: number, window: string): Promise<void>;
|
|
21
|
+
acquireQueueLock(lockKey: string, ownerId: string, ttlMs: number): Promise<boolean>;
|
|
22
|
+
releaseQueueLock(lockKey: string, ownerId: string): Promise<boolean>;
|
|
23
|
+
clearDispatchPending(lockKey: string): Promise<void>;
|
|
24
|
+
evaluateDeadRun(queueName: string, poolerType: "interval-driven-pooler" | "event-driven-pooler", totalJobs: number, continuationOwnerId: string, dispatchTtlMs?: number, idpLockKey?: string, edpLockPrefix?: string): Promise<boolean>;
|
|
25
|
+
private evalScript;
|
|
26
|
+
getStopSignal(queue: string): Promise<boolean>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=RedisQueueRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedisQueueRepository.d.ts","sourceR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AG,qBAAqB,EAC7D,SAAS,EAAG,MAAM,EAClB,mBAAmB,EAAG,MAAM,EAC5B,aAAa,GAAG,MAAc,EAC9B,UAAU,GAAG,MAAmB,EAChC,aAAa,GAAG,MAAoB,GACpC,OAAO,CAAC,OAAO,CAAC;YAiBN,UAAU;IAST,aAAa,CAAC,KAAK,EAAG,MAAM,GAAI,OAAO,CAAC,OAAO,CAAC;CAMlE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PulsarEventBus } from "../service/PulsarEventBus";
|
|
2
|
+
import type { PulsarClock } from "./PulsarClock";
|
|
3
|
+
import type { Scheduler } from "../modules/Scheduler.module";
|
|
4
|
+
import type { ILogger } from "./LoggerService";
|
|
5
|
+
import type { EngineQueuesConfig } from "@package/src/types/queue.types";
|
|
6
|
+
export declare class DeferredTickEvaluator {
|
|
7
|
+
private minBootRequirementSec;
|
|
8
|
+
private scheduler;
|
|
9
|
+
private events;
|
|
10
|
+
private clock;
|
|
11
|
+
private logger;
|
|
12
|
+
constructor(minBootRequirementSec: number, scheduler: Scheduler, events: PulsarEventBus, clock: PulsarClock, logger: ILogger);
|
|
13
|
+
private timers;
|
|
14
|
+
private watchdogTimer;
|
|
15
|
+
private isShutdownTriggered;
|
|
16
|
+
evaluateUpcomingDelayedNext(upcomingTimeMs: number, queue: string): void;
|
|
17
|
+
private startDelayedSleepWatchdog;
|
|
18
|
+
private triggerGracefulShutdown;
|
|
19
|
+
stopRuntimeWatchdog(): void;
|
|
20
|
+
clearTimer(queue: string): void;
|
|
21
|
+
forceExecuteTickLater(queue: EngineQueuesConfig, targetTimestamp: number): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=DeferredTickEvaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeferredTickEvaluator.d.ts","sourceRoot":"","sources":["../../src/subsys/DeferredTickEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,qBAAa,qBAAqB;IAE1B,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;gBAJN,qBAAqB,EAAG,MAAM,EAC9B,SAAS,EAAG,SAAS,EACrB,MAAM,EAAG,cAAc,EACvB,KAAK,EAAG,WAAW,EACnB,MAAM,EAAG,OAAO;IAG5B,OAAO,CAAC,MAAM,CAAoD;IAClE,OAAO,CAAC,aAAa,CAAgD;IACrE,OAAO,CAAC,mBAAmB,CAAS;IAE7B,2BAA2B,CAAC,cAAc,EAAG,MAAM,EAAE,KAAK,EAAG,MAAM;IAwB1E,OAAO,CAAC,yBAAyB;IAoBjC,OAAO,CAAC,uBAAuB;IAcxB,mBAAmB;IAOnB,UAAU,CAAC,KAAK,EAAG,MAAM;IASzB,qBAAqB,CAAC,KAAK,EAAG,kBAAkB,EAAE,eAAe,EAAG,MAAM;CAyBpF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type EventCallback<T = any> = (payload: T) => void;
|
|
2
|
+
export type AppModule = () => void;
|
|
3
|
+
export declare class EventBus {
|
|
4
|
+
private events;
|
|
5
|
+
private globalListeners;
|
|
6
|
+
get listenerCount(): number;
|
|
7
|
+
on(event: string, callback: EventCallback): void;
|
|
8
|
+
off(event: string, callback: EventCallback): void;
|
|
9
|
+
emit<T>(event: string, payload: T): void;
|
|
10
|
+
}
|
|
11
|
+
declare const AppEvents: EventBus;
|
|
12
|
+
export default AppEvents;
|
|
13
|
+
//# sourceMappingURL=EventBus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventBus.d.ts","sourceRoot":"","sources":["../../src/subsys/EventBus.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;AAEnD,MAAM,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC;AAEnC,qBAAa,QAAQ;IACjB,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,eAAe,CAAuB;IAE9C,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa;IAgBzC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa;IAW1C,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;CAMpC;AAED,QAAA,MAAM,SAAS,UAAiB,CAAC;AAEjC,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EngineQueuesConfig } from "../types/queue.types";
|
|
2
|
+
import type { ILogger } from "./LoggerService";
|
|
3
|
+
export declare class ExecutionProfileSwitcher {
|
|
4
|
+
private logger;
|
|
5
|
+
private transitionItems;
|
|
6
|
+
constructor(logger: ILogger);
|
|
7
|
+
transitionToIdleMode({ queue, stateTransitionPolicy }: EngineQueuesConfig): void;
|
|
8
|
+
transitionToActiveMode({ queue, profile, stateTransitionPolicy }: EngineQueuesConfig): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ExecutionProfileSwitcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecutionProfileSwitcher.d.ts","sourceRoot":"","sources":["../../src/subsys/ExecutionProfileSwitcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI/C,qBAAa,wBAAwB;IAGrB,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,eAAe,CAAqB;gBAExB,MAAM,EAAG,OAAO;IAEpC,oBAAoB,CAAC,EAAE,KAAK,EAAE,qBAAqB,EAAE,EAAG,kBAAkB;IAuB1E,sBAAsB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE,EAAG,kBAAkB;CASxF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ILogger {
|
|
2
|
+
log(message: string, ...args: any[]): void;
|
|
3
|
+
warn(message: string, ...args: any[]): void;
|
|
4
|
+
error(message: string, ...args: any[]): void;
|
|
5
|
+
debug?(message: string, ...args: any[]): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class LoggerService implements ILogger {
|
|
8
|
+
private static provider;
|
|
9
|
+
setProvider(customLogger: ILogger): void;
|
|
10
|
+
log(message: string, ...args: any[]): void;
|
|
11
|
+
warn(message: string, ...args: any[]): void;
|
|
12
|
+
error(message: string, ...args: any[]): void;
|
|
13
|
+
debug(message: string, ...args: any[]): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=LoggerService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerService.d.ts","sourceRoot":"","sources":["../../src/subsys/LoggerService.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACpB,GAAG,CAAC,OAAO,EAAG,MAAM,EAAE,GAAG,IAAI,EAAG,GAAG,EAAE,GAAI,IAAI,CAAC;IAC9C,IAAI,CAAC,OAAO,EAAG,MAAM,EAAE,GAAG,IAAI,EAAG,GAAG,EAAE,GAAI,IAAI,CAAC;IAC/C,KAAK,CAAC,OAAO,EAAG,MAAM,EAAE,GAAG,IAAI,EAAG,GAAG,EAAE,GAAI,IAAI,CAAC;IAChD,KAAK,CAAC,CAAC,OAAO,EAAG,MAAM,EAAE,GAAG,IAAI,EAAG,GAAG,EAAE,GAAI,IAAI,CAAC;CACpD;AASD,qBAAa,aAAc,YAAW,OAAO;IACzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiC;IAEjD,WAAW,CAAC,YAAY,EAAE,OAAO;IAIjC,GAAG,CAAC,OAAO,EAAG,MAAM,EAAE,GAAG,IAAI,EAAG,GAAG,EAAE;IAIrC,IAAI,CAAC,OAAO,EAAG,MAAM,EAAE,GAAG,IAAI,EAAG,GAAG,EAAE;IAItC,KAAK,CAAC,OAAO,EAAG,MAAM,EAAE,GAAG,IAAI,EAAG,GAAG,EAAE;IAIvC,KAAK,CAAC,OAAO,EAAG,MAAM,EAAE,GAAG,IAAI,EAAG,GAAG,EAAE;CAKjD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface ClockOptions {
|
|
2
|
+
/** Maximum allowed runtime in milliseconds for the entire engine execution (e.g., 25000 for 25s) */
|
|
3
|
+
maxExecutionBudgetMs?: number;
|
|
4
|
+
/** Safety margin in milliseconds reserved for graceful cleanup/shutdown */
|
|
5
|
+
safetyBufferMs?: number;
|
|
6
|
+
/** Maximum number of execution spans to retain in memory */
|
|
7
|
+
maxTrackHistory?: number;
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class PulsarClock {
|
|
11
|
+
private tracks;
|
|
12
|
+
private startTime;
|
|
13
|
+
private maxExecutionBudgetMs;
|
|
14
|
+
private safetyBufferMs;
|
|
15
|
+
private maxTrackHistory;
|
|
16
|
+
private enabled;
|
|
17
|
+
cpuExecutionMicroseconds: number;
|
|
18
|
+
constructor(options?: ClockOptions);
|
|
19
|
+
trackExecutionTime<T>({ contextId }: {
|
|
20
|
+
contextId: string;
|
|
21
|
+
}, fn: () => Promise<T>): Promise<T>;
|
|
22
|
+
getElapsedTotalTime(): number;
|
|
23
|
+
getTimeRemaining(): number;
|
|
24
|
+
getAverageTickDuration(lastN?: number): number;
|
|
25
|
+
/**
|
|
26
|
+
* Determines if executing another tick is safe.
|
|
27
|
+
* Uses recent average tick duration to estimate whether another tick will exceed the deadline.
|
|
28
|
+
*/
|
|
29
|
+
isSafeToContinue(): boolean;
|
|
30
|
+
clear(contextId: string): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=PulsarClock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PulsarClock.d.ts","sourceRoot":"","sources":["../../src/subsys/PulsarClock.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,oGAAoG;IACpG,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAA8D;IAC5E,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,OAAO,CAAU;IAElB,wBAAwB,SAAK;gBAExB,OAAO,GAAE,YAAiB;IAQzB,kBAAkB,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,EAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAmBpG,mBAAmB,IAAK,MAAM;IAI9B,gBAAgB,IAAK,MAAM;IAM3B,sBAAsB,CAAC,KAAK,SAAI,GAAG,MAAM;IAOhD;;;OAGG;IACI,gBAAgB,IAAK,OAAO;IAe5B,KAAK,CAAC,SAAS,EAAG,MAAM;CAGlC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class RuntimeCacheStorage {
|
|
2
|
+
static store: Map<string, any>;
|
|
3
|
+
kv: {
|
|
4
|
+
set: <V>(key: string, value: V) => void;
|
|
5
|
+
get: <K>(key: string) => K | undefined;
|
|
6
|
+
has: (key: string) => boolean;
|
|
7
|
+
delete: (key: string) => boolean;
|
|
8
|
+
clear: () => void;
|
|
9
|
+
};
|
|
10
|
+
lists: {
|
|
11
|
+
add: (key: string, value: string) => void;
|
|
12
|
+
remove: (key: string, value: string) => boolean;
|
|
13
|
+
get: (key: string) => Set<string> | undefined;
|
|
14
|
+
has: (key: string, value: string) => boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare const createRuntimeCacheStorage: () => RuntimeCacheStorage;
|
|
18
|
+
//# sourceMappingURL=RuntimeCacheStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeCacheStorage.d.ts","sourceRoot":"","sources":["../../src/subsys/RuntimeCacheStorage.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAmB;IAC5B,OAAc,KAAK,EAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAa;IAE5C,EAAE;cACC,CAAC,OAAQ,MAAM,SAAU,CAAC;cAI1B,CAAC,OAAQ,MAAM,KAAI,CAAC,GAAG,SAAS;mBAI1B,MAAM,KAAI,OAAO;sBAId,MAAM,KAAI,OAAO;;MAOnC;IAEM,KAAK;mBACI,MAAM,SAAU,MAAM;sBAUnB,MAAM,SAAU,MAAM;mBAQzB,MAAM,KAAI,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS;mBAKjC,MAAM,SAAU,MAAM,KAAI,OAAO;MAOhD;CACJ;AAED,eAAO,MAAM,yBAAyB,2BAAkC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PulsarUnifiedStorage } from "../storage/PulsarStorage";
|
|
2
|
+
import type { IRuntimeExecutionContext } from "../runtimes/runtimeTypes";
|
|
3
|
+
import type { ILogger } from "./LoggerService";
|
|
4
|
+
export declare class RuntimeEventBridge {
|
|
5
|
+
protected readonly storage: PulsarUnifiedStorage;
|
|
6
|
+
protected readonly logger: ILogger;
|
|
7
|
+
protected readonly runtimeExecutionId: string;
|
|
8
|
+
private readonly pgNotifyChannel;
|
|
9
|
+
private events;
|
|
10
|
+
constructor(storage: PulsarUnifiedStorage, logger: ILogger, runtimeExecutionId: string);
|
|
11
|
+
registerPgNotifyHandler(ctx: IRuntimeExecutionContext): Promise<void>;
|
|
12
|
+
registerPollingHandler(ctx: IRuntimeExecutionContext): Promise<void>;
|
|
13
|
+
httpEventDrivenQueueTrigger(queueName: string, fencingToken: string, ctx: IRuntimeExecutionContext): Promise<void>;
|
|
14
|
+
private handleTriggerValidity;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=RuntimeEventBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeEventBridge.d.ts","sourceRoot":"","sources":["../../src/subsys/RuntimeEventBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI/C,qBAAa,kBAAkB;IAMvB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAG,oBAAoB;IACjD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAG,OAAO;IACnC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAG,MAAM;IAPlD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgD;IAEhF,OAAO,CAAC,MAAM,CAAkB;gBAGT,OAAO,EAAG,oBAAoB,EAC9B,MAAM,EAAG,OAAO,EAChB,kBAAkB,EAAG,MAAM;IAKrC,uBAAuB,CAAC,GAAG,EAAG,wBAAwB;IAoBtD,sBAAsB,CAAC,GAAG,EAAG,wBAAwB;IAkBrD,2BAA2B,CAAC,SAAS,EAAG,MAAM,EAAE,YAAY,EAAG,MAAM,EAAE,GAAG,EAAG,wBAAwB;YAepG,qBAAqB;CAoCtC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { QueueModule } from "../helpers/defineQueue.d.ts";
|
|
2
|
+
import type { ILogger } from "../subsys/LoggerService.d.ts";
|
|
3
|
+
import type { PulsarUnifiedStorage } from "../storage/PulsarStorage.d.ts";
|
|
4
|
+
import type { IIntegration, IntegrationConstructor } from "./integrations.types.d.ts";
|
|
5
|
+
import type { NebulaClusterConfig } from "./nebula.types.d.ts";
|
|
6
|
+
import type { PersistentConfig, ServerlessVMConfig, V8IsolateConfig } from "./runtime.types.d.ts";
|
|
7
|
+
export interface EngineSwarmConfig {
|
|
8
|
+
maxGlobalConcurrency?: number;
|
|
9
|
+
spawnerAlgorithm?: "LEAST_CONNECTIONS" | "ROUND_ROBIN" | "CBS";
|
|
10
|
+
globalMaxJobsPerTick?: number;
|
|
11
|
+
}
|
|
12
|
+
export type BaseEngineConfig = {
|
|
13
|
+
instanceId: string;
|
|
14
|
+
/**
|
|
15
|
+
* Specifies the shared API key for this instance.
|
|
16
|
+
* The key is generated once and must be identical across
|
|
17
|
+
* all consumer configurations targeting this instance.
|
|
18
|
+
*
|
|
19
|
+
* Generate a secure API key using:
|
|
20
|
+
* @example
|
|
21
|
+
* openssl rand -hex 32
|
|
22
|
+
* @or generate online
|
|
23
|
+
* https://generate-random.org/api-keys
|
|
24
|
+
*/
|
|
25
|
+
apiKey: string;
|
|
26
|
+
nebula?: NebulaClusterConfig;
|
|
27
|
+
/**
|
|
28
|
+
* The unified storage layer responsible for state management, queue operations, and distributed locks.
|
|
29
|
+
*
|
|
30
|
+
* The engine requires **PostgreSQL** as its core underlying storage driver to handle fundamental database
|
|
31
|
+
* functions and lock tables. However, adding **Redis** to the unified storage driver unlocks an optimized
|
|
32
|
+
* dual-layer storage architecture.
|
|
33
|
+
*
|
|
34
|
+
* When Redis is configured alongside PostgreSQL, the engine automatically offloads high frequency,
|
|
35
|
+
* heavy throughput read and write operations—such as worker registration, batch dispatches, and job
|
|
36
|
+
* acknowledgments to Redis memory.
|
|
37
|
+
*
|
|
38
|
+
* ### Storage Mode Behavior:
|
|
39
|
+
* * **PostgreSQL Only:** Handles all state persistence, transactional safety, and queue operations directly on the database.
|
|
40
|
+
* * **PostgreSQL + Redis (Recommended):** Offloads runtime operational load from PostgreSQL to Redis memory,
|
|
41
|
+
* significantly reducing database pressure and boosting overall engine processing speeds and throughput by 25% or more.
|
|
42
|
+
*/
|
|
43
|
+
storage: PulsarUnifiedStorage;
|
|
44
|
+
queues: QueueModule[];
|
|
45
|
+
/**
|
|
46
|
+
* Consumer configuration for HTTP endpoints.
|
|
47
|
+
* When provided, Pulsar will make POST requests to this URL for each job.
|
|
48
|
+
* The job payload will be sent in the request body.
|
|
49
|
+
*/
|
|
50
|
+
swarmConfig?: EngineSwarmConfig;
|
|
51
|
+
integrations?: Array<IntegrationConstructor | IIntegration>;
|
|
52
|
+
logger?: ILogger;
|
|
53
|
+
onEvents?: {
|
|
54
|
+
queueComplete?: (ctx: {
|
|
55
|
+
queue: string;
|
|
56
|
+
at: number;
|
|
57
|
+
}) => Promise<void> | void;
|
|
58
|
+
engineRestart?: () => Promise<void>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Primary engine configuration union with runtime-level type enforcement.
|
|
63
|
+
*/
|
|
64
|
+
export type EngineConfig = V8IsolateConfig | ServerlessVMConfig | PersistentConfig;
|
|
65
|
+
//# sourceMappingURL=base.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.types.d.ts","sourceRoot":"","sources":["../../src/types/base.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4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|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { EventTriggerStrategy } from "./eventTriggerStrategry.types";
|
|
2
|
+
import type { PulsarRuntime } from "./runtime.types";
|
|
3
|
+
type RawPathKeys<T> = T extends object ? {
|
|
4
|
+
[K in keyof T & (string | number)]: T[K] extends Array<any> ? `${K}` : T[K] extends object ? `${K}` | `${K}.${RawPathKeys<T[K]>}` : `${K}`;
|
|
5
|
+
}[keyof T & (string | number)] : never;
|
|
6
|
+
/**
|
|
7
|
+
* Define exact paths or prefix patterns that MUST NOT be mutated via set().
|
|
8
|
+
* - 'storage' | 'storage.${string}': Storage instance should not be swapped on the fly.
|
|
9
|
+
* - 'runtime': Prevents switching execution environment at runtime.
|
|
10
|
+
* - 'onEvents' | 'onEvents.${string}': Prevents overwriting event hooks.
|
|
11
|
+
*/
|
|
12
|
+
type BlockedPaths = "storage" | `storage.${string}` | "runtime" | "onEvents" | `onEvents.${string}` | "isolate" | `isolate.${string}`;
|
|
13
|
+
/**
|
|
14
|
+
* Filtered paths allowed specifically for `set()` operations.
|
|
15
|
+
*/
|
|
16
|
+
export type SettablePathKeys<T> = Exclude<RawPathKeys<T>, BlockedPaths>;
|
|
17
|
+
/**
|
|
18
|
+
* All paths available for `get()` operations (unrestricted read access).
|
|
19
|
+
*/
|
|
20
|
+
export type ReadablePathKeys<T> = RawPathKeys<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Type utility to infer the value type corresponding to a dot-notation path string.
|
|
23
|
+
*/
|
|
24
|
+
export type PathValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? PathValue<T[K], Rest> : never : P extends keyof T ? T[P] : never;
|
|
25
|
+
export interface IConfigurationObject {
|
|
26
|
+
queues: Array<{
|
|
27
|
+
queue: string;
|
|
28
|
+
pooler: string;
|
|
29
|
+
}>;
|
|
30
|
+
self_url: string;
|
|
31
|
+
runtime: PulsarRuntime;
|
|
32
|
+
event_trigger_strategy: EventTriggerStrategy;
|
|
33
|
+
}
|
|
34
|
+
export interface IConfigSyncResult {
|
|
35
|
+
isChanged: boolean;
|
|
36
|
+
isNew: boolean;
|
|
37
|
+
oldConfigurations?: IConfigurationObject;
|
|
38
|
+
delta?: {
|
|
39
|
+
urlChanged: boolean;
|
|
40
|
+
addedQueues: Array<{
|
|
41
|
+
queue: string;
|
|
42
|
+
pooler: string;
|
|
43
|
+
}>;
|
|
44
|
+
removedQueues: Array<{
|
|
45
|
+
queue: string;
|
|
46
|
+
pooler: string;
|
|
47
|
+
}>;
|
|
48
|
+
modifiedQueues: Array<{
|
|
49
|
+
queue: string;
|
|
50
|
+
oldPooler: string;
|
|
51
|
+
newPooler: string;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=config.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../src/types/config.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAClC;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,GACvD,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAC5B,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE;CAClD,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,GAC9B,KAAK,CAAC;AAEV;;;;;GAKG;AACH,KAAK,YAAY,GACb,S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EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACxD,cAAc,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAClF,CAAA;CACJ"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type JobContext<T = any> = {
|
|
2
|
+
/**
|
|
3
|
+
* The ID Of Worker Which Picked This Batch
|
|
4
|
+
*
|
|
5
|
+
* When using callback, the consumer must deregister using this worker id for freeing up the slot
|
|
6
|
+
***/
|
|
7
|
+
workerId: string;
|
|
8
|
+
/***
|
|
9
|
+
* The ID Of The Queue From Which This Batch Was Picked
|
|
10
|
+
***/
|
|
11
|
+
queue: string;
|
|
12
|
+
/***
|
|
13
|
+
* The Payloads Of The Batch
|
|
14
|
+
***/
|
|
15
|
+
payload: T;
|
|
16
|
+
/***
|
|
17
|
+
* The Number Of Attempts This Job Has Undergone
|
|
18
|
+
***/
|
|
19
|
+
attempts: number;
|
|
20
|
+
timestamp: number;
|
|
21
|
+
};
|
|
22
|
+
export type EngineConsumerConfig = {
|
|
23
|
+
type: "http";
|
|
24
|
+
queue: string;
|
|
25
|
+
url: string;
|
|
26
|
+
headers?: Record<string, string>;
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
} | {
|
|
29
|
+
type: "socket";
|
|
30
|
+
queue: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: "callback";
|
|
33
|
+
queue: string;
|
|
34
|
+
handler(job: JobContext): Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=consumer.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumer.types.d.ts","sourceRoot":"","sources":["../../src/types/consumer.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,GAAG,IAAI;IAC9B;;;;QAII;IACJ,QAAQ,EAAG,MAAM,CAAC;IAElB;;QAEI;IACJ,KAAK,EAAG,MAAM,CAAC;IAEf;;QAEI;IACJ,OAAO,EAAG,CAAC,CAAC;IAEZ;;QAEI;IACJ,QAAQ,EAAG,MAAM,CAAC;IAClB,SAAS,EAAG,MAAM,CAAC;CACtB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAC5B;IACE,IAAI,EAAG,MAAM,CAAC;IACd,KAAK,EAAG,MAAM,CAAC;IACf,GAAG,EAAG,MAAM,CAAC;IACb,OAAO,CAAC,EAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,SAAS,CAAC,EAAG,MAAM,CAAC;CACrB,GACD;IACE,IAAI,EAAG,QAAQ,CAAC;IAChB,KAAK,EAAG,MAAM,CAAC;CAChB,GACD;IACA,IAAI,EAAG,UAAU,CAAC;IAClB,KAAK,EAAG,MAAM,CAAC;IACf,OAAO,CAAC,GAAG,EAAG,UAAU,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export type EnginePoolingMode = 'interval-driven-pooler' | 'event-driven-pooler';
|
|
2
|
+
export type EngineSelfInvocation = {
|
|
3
|
+
selfURL: string;
|
|
4
|
+
selfInvocationMethod?: "auto_using_pgnet";
|
|
5
|
+
} | {
|
|
6
|
+
selfURL: string;
|
|
7
|
+
selfInvocationMethod?: "manual";
|
|
8
|
+
handler: (selfUrl: string) => Promise<void> | void;
|
|
9
|
+
};
|
|
10
|
+
type BaseEngineOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* The global maximum ceiling for total tick executions across ALL queues in a single execution run.
|
|
13
|
+
*
|
|
14
|
+
* Once the cumulative number of ticks executed across all queues reaches this limit,
|
|
15
|
+
* the engine terminates the current execution cycle and triggers a self-invocation restart.
|
|
16
|
+
*
|
|
17
|
+
* ### Execution Flow:
|
|
18
|
+
* ```
|
|
19
|
+
* [ Queue Ticks Executed ] ──(Count reaches cycleTickLimit)──> [ Terminate Cycle & Self-Invoke ]
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* For example, with 10 queues and `cycleTickLimit: 10`, each queue executes 1 tick before
|
|
23
|
+
* the engine reaches the global limit and restarts, ensuring no single queue consumes
|
|
24
|
+
* the entire execution window.
|
|
25
|
+
*
|
|
26
|
+
* @default Infinity
|
|
27
|
+
*/
|
|
28
|
+
cycleTickLimit?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Controls the execution strategy for dispatching tick cycles across target queues.
|
|
31
|
+
*
|
|
32
|
+
* This setting dictates whether the engine evaluates and triggers ticks across multiple
|
|
33
|
+
* configured queues sequentially (one queue at a time) or in parallel (simultaneously).
|
|
34
|
+
*
|
|
35
|
+
* ### Execution Flow Comparison:
|
|
36
|
+
*
|
|
37
|
+
* **`sequential` (Default - CPU & Memory Safe):**
|
|
38
|
+
* ```
|
|
39
|
+
* [ Queue A Tick ] ──(await completion)──> [ Queue B Tick ] ──(await completion)──> [ Queue C Tick ]
|
|
40
|
+
* ```
|
|
41
|
+
* * **Behavior:** Processes queue ticks strictly one after another in serial order.
|
|
42
|
+
* * **Pros:** Keeps CPU usage steady and avoids sudden spike loads on database connections and memory isolates.
|
|
43
|
+
* * **Cons:** Takes longer total clock time to complete a single tick cycle across all queues.
|
|
44
|
+
*
|
|
45
|
+
* **`parallel` (High Throughput - Higher Resource Demand):**
|
|
46
|
+
* ```
|
|
47
|
+
* ┌─> [ Queue A Tick ]
|
|
48
|
+
* ├─> [ Queue B Tick ] ─── (Fired simultaneously via Promise.allSettled)
|
|
49
|
+
* └─> [ Queue C Tick ]
|
|
50
|
+
* ```
|
|
51
|
+
* * **Behavior:** Dispatches tick evaluations for all candidate queues at the exact same moment.
|
|
52
|
+
* * **Pros:** Dramatically lowers cycle latency and maximizes total job processing throughput.
|
|
53
|
+
* * **Cons:** Produces concurrent CPU spikes, higher transient V8 memory allocations, and heavier concurrent database query bursts.
|
|
54
|
+
*
|
|
55
|
+
* > **Performance Note:** Choosing between `sequential` and `parallel` directly impacts engine resource utilization.
|
|
56
|
+
* > In environments with strict CPU time allocations or tight database connection limits, `sequential` prevents resource starvation.
|
|
57
|
+
* > For high-capacity environments prioritizing low dispatch latency across many queues, `parallel` delivers optimal speed.
|
|
58
|
+
*
|
|
59
|
+
* @default "sequential"
|
|
60
|
+
*/
|
|
61
|
+
tickConcurrency?: "parallel" | "sequential";
|
|
62
|
+
/**
|
|
63
|
+
* How often (in seconds) the engine checks its own internal health and runtime state.
|
|
64
|
+
*
|
|
65
|
+
* @default 15
|
|
66
|
+
*/
|
|
67
|
+
healthCheckIntervalSec?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Defines the default engine wide intervention policy for handling external cancellation or stop signals.
|
|
70
|
+
*
|
|
71
|
+
* Queues configured with a policy of `"inherit"` will automatically adopt this global setting.
|
|
72
|
+
* When an external stop or intervention signal is triggered this policy dictates how the engine
|
|
73
|
+
* evaluates the signal and terminates the tick process:
|
|
74
|
+
*
|
|
75
|
+
* - `tick`: The engine checks the intervention flag on every single atomic tick iteration.
|
|
76
|
+
* When a stop signal is detected, the engine aborts execution immediately within the current tick
|
|
77
|
+
* boundary, ensuring near instantaneous cessation at the cost of higher cache/storage I/O.
|
|
78
|
+
* ---
|
|
79
|
+
* - `cycle`: The engine allows the active tick loop to run continuously through the completion
|
|
80
|
+
* of a full batch cycle. The signal is only evaluated during the cycle reset boundary after
|
|
81
|
+
* which the engine cleanly exits the loop (zero runtime overhead during active crunching but
|
|
82
|
+
* introduces latency proportional to cycle length).
|
|
83
|
+
* ---
|
|
84
|
+
*- `disabled`: All external cancellation and intervention signals are ignored.
|
|
85
|
+
* The engine will not evaluate, acknowledge, or act upon incoming stop signals,
|
|
86
|
+
* allowing active tick processes to continue uninterrupted until normal completion.
|
|
87
|
+
* This effectively disables external intervention across all queues inheriting this policy.
|
|
88
|
+
*
|
|
89
|
+
* @default "disabled"
|
|
90
|
+
*/
|
|
91
|
+
interventionPolicy?: 'tick' | 'cycle' | 'disabled';
|
|
92
|
+
};
|
|
93
|
+
export type SelfInvokingEngine = BaseEngineOptions & {
|
|
94
|
+
selfURL: string;
|
|
95
|
+
selfInvocationMethod?: "auto_using_pgnet" | {
|
|
96
|
+
method: "manual";
|
|
97
|
+
handler: (selfUrl: string) => Promise<void> | void;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Specifies how often (in seconds) the engine should invoke itself.
|
|
101
|
+
*
|
|
102
|
+
* The minimum value is **1 second**. A higher number increases the delay
|
|
103
|
+
* between self-invocations.
|
|
104
|
+
*
|
|
105
|
+
* ### Recommendations & Workload Pacing
|
|
106
|
+
* * It is generally **recommended to keep the default (1 second)**.
|
|
107
|
+
* * Increasing this value introduces processing latency before jobs are picked up.
|
|
108
|
+
* * **Lower values (e.g., 1s)** process jobs faster and are recommended if you have
|
|
109
|
+
* multiple interval-driven queues with frequent, predictable workloads.
|
|
110
|
+
* * **Higher values (e.g., 5s)** process jobs slower but significantly reduce the
|
|
111
|
+
* total number of engine invocations over time.
|
|
112
|
+
*
|
|
113
|
+
* ### Estimated Monthly Invocations
|
|
114
|
+
* The lower this setting is, the higher the total invocation count will be at the
|
|
115
|
+
* end of the month.
|
|
116
|
+
*
|
|
117
|
+
* **1 Second Interval:**
|
|
118
|
+
* * Formula: `1 second * 60 seconds * 60 minutes * 24 hours * 30 days`
|
|
119
|
+
* * Total: **~2,592,000 invocations / month**
|
|
120
|
+
*
|
|
121
|
+
* **5 Seconds Interval:**
|
|
122
|
+
* * Formula: `(1 second / 5) * 60 seconds * 60 minutes * 24 hours * 30 days`
|
|
123
|
+
* * Total: **~518,400 invocations / month**
|
|
124
|
+
*
|
|
125
|
+
* *(Note: Depending on your hosting platform, actual invocation counts may be slightly
|
|
126
|
+
* higher or lower based on execution overhead).*
|
|
127
|
+
*
|
|
128
|
+
* @default 1
|
|
129
|
+
* @minimum 1
|
|
130
|
+
*/
|
|
131
|
+
selfInvocationIntervalSec?: number;
|
|
132
|
+
selfRestartIntervalSec?: number;
|
|
133
|
+
};
|
|
134
|
+
export type PersistentEngine = BaseEngineOptions & {
|
|
135
|
+
poolingMode?: EnginePoolingMode;
|
|
136
|
+
poolingIntervalMS?: number;
|
|
137
|
+
};
|
|
138
|
+
export {};
|
|
139
|
+
//# sourceMappingURL=engine.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.types.d.ts","sourceRoot":"","sources":["../../src/types/engine.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,wBAAwB,GAAG,qBAAqB,CAAC;AAEjF,MAAM,MAAM,oBAAoB,GAC5B;IAAE,OAAO,EAAG,MAAM,CAAC;IAAC,oBAAoB,CAAC,EAAG,kBAAkB,CAAA;CAAE,GAChE;IAAE,OAAO,EAAG,MAAM,CAAC;IAAC,oBAAoB,CAAC,EAAG,QAAQ,CAAC;IAAC,OAAO,EAAG,CAAC,OAAO,EAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAAE,CAAA;AAEhH,KAAK,iBAAiB,GAAG;IACrB;;;;;;;;;;;;;;;;MAgBE;IACF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,eAAe,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IAC5C;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,kBAAkB,CAAC,EAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;CACvD,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,kBAAkB,GAAG;QAAE,MAAM,EAAE,QAAQ,CAAC;QAAC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI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