@pgflow/edge-worker 0.1.14 → 0.1.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/dist/package.json +1 -1
- package/package.json +4 -4
- package/dist/CHANGELOG.md +0 -268
- package/dist/EdgeWorker.d.ts +0 -121
- package/dist/EdgeWorker.d.ts.map +0 -1
- package/dist/EdgeWorker.js +0 -168
- package/dist/LICENSE.md +0 -660
- package/dist/README.md +0 -46
- package/dist/core/BatchProcessor.d.ts +0 -13
- package/dist/core/BatchProcessor.d.ts.map +0 -1
- package/dist/core/BatchProcessor.js +0 -29
- package/dist/core/ExecutionController.d.ts +0 -15
- package/dist/core/ExecutionController.d.ts.map +0 -1
- package/dist/core/ExecutionController.js +0 -34
- package/dist/core/Heartbeat.d.ts +0 -13
- package/dist/core/Heartbeat.d.ts.map +0 -1
- package/dist/core/Heartbeat.js +0 -21
- package/dist/core/Queries.d.ts +0 -14
- package/dist/core/Queries.d.ts.map +0 -1
- package/dist/core/Queries.js +0 -31
- package/dist/core/Worker.d.ts +0 -21
- package/dist/core/Worker.d.ts.map +0 -1
- package/dist/core/Worker.js +0 -79
- package/dist/core/WorkerLifecycle.d.ts +0 -26
- package/dist/core/WorkerLifecycle.d.ts.map +0 -1
- package/dist/core/WorkerLifecycle.js +0 -69
- package/dist/core/WorkerState.d.ts +0 -37
- package/dist/core/WorkerState.d.ts.map +0 -1
- package/dist/core/WorkerState.js +0 -70
- package/dist/core/types.d.ts +0 -39
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js +0 -1
- package/dist/flow/FlowWorkerLifecycle.d.ts +0 -26
- package/dist/flow/FlowWorkerLifecycle.d.ts.map +0 -1
- package/dist/flow/FlowWorkerLifecycle.js +0 -64
- package/dist/flow/StepTaskExecutor.d.ts +0 -28
- package/dist/flow/StepTaskExecutor.d.ts.map +0 -1
- package/dist/flow/StepTaskExecutor.js +0 -71
- package/dist/flow/StepTaskPoller.d.ts +0 -21
- package/dist/flow/StepTaskPoller.d.ts.map +0 -1
- package/dist/flow/StepTaskPoller.js +0 -34
- package/dist/flow/createFlowWorker.d.ts +0 -42
- package/dist/flow/createFlowWorker.d.ts.map +0 -1
- package/dist/flow/createFlowWorker.js +0 -56
- package/dist/flow/types.d.ts +0 -2
- package/dist/flow/types.d.ts.map +0 -1
- package/dist/flow/types.js +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/platform/DenoAdapter.d.ts +0 -39
- package/dist/platform/DenoAdapter.d.ts.map +0 -1
- package/dist/platform/DenoAdapter.js +0 -126
- package/dist/platform/createAdapter.d.ts +0 -6
- package/dist/platform/createAdapter.d.ts.map +0 -1
- package/dist/platform/createAdapter.js +0 -16
- package/dist/platform/index.d.ts +0 -4
- package/dist/platform/index.d.ts.map +0 -1
- package/dist/platform/index.js +0 -3
- package/dist/platform/logging.d.ts +0 -10
- package/dist/platform/logging.d.ts.map +0 -1
- package/dist/platform/logging.js +0 -68
- package/dist/platform/types.d.ts +0 -37
- package/dist/platform/types.d.ts.map +0 -1
- package/dist/platform/types.js +0 -1
- package/dist/queue/MessageExecutor.d.ts +0 -43
- package/dist/queue/MessageExecutor.d.ts.map +0 -1
- package/dist/queue/MessageExecutor.js +0 -95
- package/dist/queue/Queue.d.ts +0 -35
- package/dist/queue/Queue.d.ts.map +0 -1
- package/dist/queue/Queue.js +0 -87
- package/dist/queue/ReadWithPollPoller.d.ts +0 -20
- package/dist/queue/ReadWithPollPoller.d.ts.map +0 -1
- package/dist/queue/ReadWithPollPoller.js +0 -25
- package/dist/queue/createQueueWorker.d.ts +0 -75
- package/dist/queue/createQueueWorker.d.ts.map +0 -1
- package/dist/queue/createQueueWorker.js +0 -47
- package/dist/queue/types.d.ts +0 -17
- package/dist/queue/types.d.ts.map +0 -1
- package/dist/queue/types.js +0 -1
package/dist/README.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<h1>Edge Worker</h1>
|
|
3
|
-
<a href="https://pgflow.dev">
|
|
4
|
-
<h3>📚 Documentation @ pgflow.dev</h3>
|
|
5
|
-
</a>
|
|
6
|
-
|
|
7
|
-
<h4>⚠️ <strong>ADVANCED PROOF of CONCEPT - NOT PRODUCTION READY</strong> ⚠️</h4>
|
|
8
|
-
</div>
|
|
9
|
-
|
|
10
|
-
A task queue worker for Supabase Edge Functions that extends background tasks with useful features.
|
|
11
|
-
|
|
12
|
-
> [!NOTE]
|
|
13
|
-
> This project is licensed under [AGPL v3](./LICENSE.md) license and is part of **pgflow** stack.
|
|
14
|
-
> See [LICENSING_OVERVIEW.md](../../LICENSING_OVERVIEW.md) in root of this monorepo for more details.
|
|
15
|
-
|
|
16
|
-
## What is Edge Worker?
|
|
17
|
-
|
|
18
|
-
Edge Worker processes messages from a queue and executes user-defined functions with their payloads. It builds upon [Supabase Background Tasks](https://supabase.com/docs/guides/functions/background-tasks) to add reliability features like retries, concurrency control and monitoring.
|
|
19
|
-
|
|
20
|
-
## Key Features
|
|
21
|
-
|
|
22
|
-
- ⚡ **Reliable Processing**: Retries with configurable delays
|
|
23
|
-
- 🔄 **Concurrency Control**: Limit parallel task execution
|
|
24
|
-
- 📊 **Observability**: Built-in heartbeats and logging
|
|
25
|
-
- 📈 **Horizontal Scaling**: Deploy multiple edge functions for the same queue
|
|
26
|
-
- 🛡️ **Edge-Native**: Designed for Edge Functions' CPU/clock limits
|
|
27
|
-
|
|
28
|
-
## How It Works
|
|
29
|
-
|
|
30
|
-
[](https://mermaid.live/edit#pako:eNplkcFugzAMhl8lyrl9AQ47VLBxqdSqlZAGHEziASokyEkmTaXvvoR0o1VziGL_n_9Y9pULLZEnvFItwdSxc1op5o9xTUxU_OQmaMAgy2SL7N0pYXutTMUjGU5WlItYaLog1VFAJSv14paCXdweyw8f-2MZLnZ06LBelXxXRk_DztAM-Gp9KA-kpRP-W7bdvs3Ga4aNaAy0OC_WdzD4B4IQVsLMvvkIZMUiA4mu_8ZHYjW5MxNp4dUnKC9zUHJA-h9R_VQTG-sQyDYINlTs-IaPSCP00q_gGvCK2w5HP53EPyXQJczp5jlwVp9-lOCJJYcbTtq13V_gJgkW0x78lEeefMFgfHYC9an1GqPsraZ9XPiy99svlAqmtA)
|
|
31
|
-
|
|
32
|
-
## Edge Function Optimization
|
|
33
|
-
|
|
34
|
-
Edge Worker is specifically designed to handle Edge Function limitations:
|
|
35
|
-
|
|
36
|
-
- Stops polling near CPU/clock limits
|
|
37
|
-
- Gracefully aborts pending tasks
|
|
38
|
-
- Uses PGMQ's visibility timeout to prevent message loss
|
|
39
|
-
- Auto-spawns new instances for continuous operation
|
|
40
|
-
- Monitors worker health with database heartbeats
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## Documentation
|
|
44
|
-
|
|
45
|
-
For detailed documentation and getting started guide, visit [pgflow.dev](https://pgflow.dev).
|
|
46
|
-
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ExecutionController } from './ExecutionController.js';
|
|
2
|
-
import type { IMessage, IPoller } from './types.js';
|
|
3
|
-
import type { Logger } from '../platform/types.js';
|
|
4
|
-
export declare class BatchProcessor<TMessage extends IMessage> {
|
|
5
|
-
private executionController;
|
|
6
|
-
private poller;
|
|
7
|
-
private signal;
|
|
8
|
-
private logger;
|
|
9
|
-
constructor(executionController: ExecutionController<TMessage>, poller: IPoller<TMessage>, signal: AbortSignal, logger: Logger);
|
|
10
|
-
processBatch(): Promise<void>;
|
|
11
|
-
awaitCompletion(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=BatchProcessor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BatchProcessor.d.ts","sourceRoot":"","sources":["../../src/core/BatchProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,cAAc,CAAC,QAAQ,SAAS,QAAQ;IAIjD,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IALhB,OAAO,CAAC,MAAM,CAAS;gBAGb,mBAAmB,EAAE,mBAAmB,CAAC,QAAQ,CAAC,EAClD,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,EACzB,MAAM,EAAE,WAAW,EAC3B,MAAM,EAAE,MAAM;IAQV,YAAY;IAiBZ,eAAe;CAGtB"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export class BatchProcessor {
|
|
2
|
-
executionController;
|
|
3
|
-
poller;
|
|
4
|
-
signal;
|
|
5
|
-
logger;
|
|
6
|
-
constructor(executionController, poller, signal, logger) {
|
|
7
|
-
this.executionController = executionController;
|
|
8
|
-
this.poller = poller;
|
|
9
|
-
this.signal = signal;
|
|
10
|
-
this.executionController = executionController;
|
|
11
|
-
this.signal = signal;
|
|
12
|
-
this.poller = poller;
|
|
13
|
-
this.logger = logger;
|
|
14
|
-
}
|
|
15
|
-
async processBatch() {
|
|
16
|
-
this.logger.debug('Polling for new batch of messages...');
|
|
17
|
-
const messageRecords = await this.poller.poll();
|
|
18
|
-
if (this.signal.aborted) {
|
|
19
|
-
this.logger.info('Discarding messageRecords because worker is stopping');
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
this.logger.debug(`Starting ${messageRecords.length} messages`);
|
|
23
|
-
const startPromises = messageRecords.map((message) => this.executionController.start(message));
|
|
24
|
-
await Promise.all(startPromises);
|
|
25
|
-
}
|
|
26
|
-
async awaitCompletion() {
|
|
27
|
-
return await this.executionController.awaitCompletion();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { IExecutor, IMessage } from './types.js';
|
|
2
|
-
import type { Logger } from '../platform/types.js';
|
|
3
|
-
export interface ExecutionConfig {
|
|
4
|
-
maxConcurrent: number;
|
|
5
|
-
}
|
|
6
|
-
export declare class ExecutionController<TMessage extends IMessage> {
|
|
7
|
-
private logger;
|
|
8
|
-
private promiseQueue;
|
|
9
|
-
private signal;
|
|
10
|
-
private createExecutor;
|
|
11
|
-
constructor(executorFactory: (record: TMessage, signal: AbortSignal) => IExecutor, abortSignal: AbortSignal, config: ExecutionConfig, logger: Logger);
|
|
12
|
-
start(record: TMessage): Promise<void>;
|
|
13
|
-
awaitCompletion(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=ExecutionController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExecutionController.d.ts","sourceRoot":"","sources":["../../src/core/ExecutionController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,mBAAmB,CAAC,QAAQ,SAAS,QAAQ;IACxD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,cAAc,CAAuD;gBAG3E,eAAe,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,KAAK,SAAS,EACrE,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM;IAQV,KAAK,CAAC,MAAM,EAAE,QAAQ;IAiBtB,eAAe;CAStB"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { newQueue } from '@henrygd/queue';
|
|
2
|
-
export class ExecutionController {
|
|
3
|
-
logger;
|
|
4
|
-
promiseQueue;
|
|
5
|
-
signal;
|
|
6
|
-
createExecutor;
|
|
7
|
-
constructor(executorFactory, abortSignal, config, logger) {
|
|
8
|
-
this.signal = abortSignal;
|
|
9
|
-
this.createExecutor = executorFactory;
|
|
10
|
-
this.promiseQueue = newQueue(config.maxConcurrent);
|
|
11
|
-
this.logger = logger;
|
|
12
|
-
}
|
|
13
|
-
async start(record) {
|
|
14
|
-
const executor = this.createExecutor(record, this.signal);
|
|
15
|
-
this.logger.info(`Scheduling execution of task ${executor.msgId}`);
|
|
16
|
-
return await this.promiseQueue.add(async () => {
|
|
17
|
-
try {
|
|
18
|
-
this.logger.debug(`Executing task ${executor.msgId}...`);
|
|
19
|
-
await executor.execute();
|
|
20
|
-
this.logger.debug(`Execution successful for ${executor.msgId}`);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
this.logger.error(`Execution failed for ${executor.msgId}:`, error);
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
async awaitCompletion() {
|
|
29
|
-
const active = this.promiseQueue.active();
|
|
30
|
-
const all = this.promiseQueue.size();
|
|
31
|
-
this.logger.debug(`Awaiting completion of all tasks... (active/all: ${active}}/${all})`);
|
|
32
|
-
await this.promiseQueue.done();
|
|
33
|
-
}
|
|
34
|
-
}
|
package/dist/core/Heartbeat.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Queries } from './Queries.js';
|
|
2
|
-
import type { WorkerRow } from './types.js';
|
|
3
|
-
import type { Logger } from '../platform/types.js';
|
|
4
|
-
export declare class Heartbeat {
|
|
5
|
-
private interval;
|
|
6
|
-
private queries;
|
|
7
|
-
private workerRow;
|
|
8
|
-
private logger;
|
|
9
|
-
private lastHeartbeat;
|
|
10
|
-
constructor(interval: number, queries: Queries, workerRow: WorkerRow, logger: Logger);
|
|
11
|
-
send(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=Heartbeat.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Heartbeat.d.ts","sourceRoot":"","sources":["../../src/core/Heartbeat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,SAAS;IAKlB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,SAAS;IANnB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAK;gBAGhB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EAC5B,MAAM,EAAE,MAAM;IAKV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
|
package/dist/core/Heartbeat.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export class Heartbeat {
|
|
2
|
-
interval;
|
|
3
|
-
queries;
|
|
4
|
-
workerRow;
|
|
5
|
-
logger;
|
|
6
|
-
lastHeartbeat = 0;
|
|
7
|
-
constructor(interval, queries, workerRow, logger) {
|
|
8
|
-
this.interval = interval;
|
|
9
|
-
this.queries = queries;
|
|
10
|
-
this.workerRow = workerRow;
|
|
11
|
-
this.logger = logger;
|
|
12
|
-
}
|
|
13
|
-
async send() {
|
|
14
|
-
const now = Date.now();
|
|
15
|
-
if (now - this.lastHeartbeat >= this.interval) {
|
|
16
|
-
await this.queries.sendHeartbeat(this.workerRow);
|
|
17
|
-
this.logger.debug('OK');
|
|
18
|
-
this.lastHeartbeat = now;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
package/dist/core/Queries.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type postgres from 'postgres';
|
|
2
|
-
import type { WorkerRow } from './types.js';
|
|
3
|
-
export declare class Queries {
|
|
4
|
-
private readonly sql;
|
|
5
|
-
constructor(sql: postgres.Sql);
|
|
6
|
-
onWorkerStarted({ queueName, workerId, edgeFunctionName, }: {
|
|
7
|
-
queueName: string;
|
|
8
|
-
workerId: string;
|
|
9
|
-
edgeFunctionName: string;
|
|
10
|
-
}): Promise<WorkerRow>;
|
|
11
|
-
onWorkerStopped(workerRow: WorkerRow): Promise<WorkerRow>;
|
|
12
|
-
sendHeartbeat(workerRow: WorkerRow): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=Queries.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Queries.d.ts","sourceRoot":"","sources":["../../src/core/Queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,QAAQ,CAAC,GAAG;IAExC,eAAe,CAAC,EACpB,SAAS,EACT,QAAQ,EACR,gBAAgB,GACjB,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,GAAG,OAAO,CAAC,SAAS,CAAC;IAUhB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAWzD,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAQzD"}
|
package/dist/core/Queries.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export class Queries {
|
|
2
|
-
sql;
|
|
3
|
-
constructor(sql) {
|
|
4
|
-
this.sql = sql;
|
|
5
|
-
}
|
|
6
|
-
async onWorkerStarted({ queueName, workerId, edgeFunctionName, }) {
|
|
7
|
-
const [worker] = await this.sql `
|
|
8
|
-
INSERT INTO edge_worker.workers (queue_name, worker_id, function_name)
|
|
9
|
-
VALUES (${queueName}, ${workerId}, ${edgeFunctionName})
|
|
10
|
-
RETURNING *;
|
|
11
|
-
`;
|
|
12
|
-
return worker;
|
|
13
|
-
}
|
|
14
|
-
async onWorkerStopped(workerRow) {
|
|
15
|
-
const [worker] = await this.sql `
|
|
16
|
-
UPDATE edge_worker.workers AS w
|
|
17
|
-
SET stopped_at = clock_timestamp(), last_heartbeat_at = clock_timestamp()
|
|
18
|
-
WHERE w.worker_id = ${workerRow.worker_id}
|
|
19
|
-
RETURNING *;
|
|
20
|
-
`;
|
|
21
|
-
return worker;
|
|
22
|
-
}
|
|
23
|
-
async sendHeartbeat(workerRow) {
|
|
24
|
-
await this.sql `
|
|
25
|
-
UPDATE edge_worker.workers AS w
|
|
26
|
-
SET last_heartbeat_at = clock_timestamp()
|
|
27
|
-
WHERE w.worker_id = ${workerRow.worker_id}
|
|
28
|
-
RETURNING *;
|
|
29
|
-
`;
|
|
30
|
-
}
|
|
31
|
-
}
|
package/dist/core/Worker.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type postgres from 'postgres';
|
|
2
|
-
import type { IBatchProcessor, ILifecycle, WorkerBootstrap } from './types.js';
|
|
3
|
-
import type { Logger } from '../platform/types.js';
|
|
4
|
-
export declare class Worker {
|
|
5
|
-
private lifecycle;
|
|
6
|
-
private logger;
|
|
7
|
-
private abortController;
|
|
8
|
-
private batchProcessor;
|
|
9
|
-
private sql;
|
|
10
|
-
constructor(batchProcessor: IBatchProcessor, lifecycle: ILifecycle, sql: postgres.Sql, logger: Logger);
|
|
11
|
-
startOnlyOnce(workerBootstrap: WorkerBootstrap): Promise<void>;
|
|
12
|
-
private start;
|
|
13
|
-
stop(): Promise<void>;
|
|
14
|
-
get edgeFunctionName(): string | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Returns true if worker state is Running and worker was not stopped
|
|
17
|
-
*/
|
|
18
|
-
private get isMainLoopActive();
|
|
19
|
-
private get isAborted();
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=Worker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../src/core/Worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,MAAM;IACjB,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,eAAe,CAAyB;IAEhD,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,GAAG,CAAe;gBAGxB,cAAc,EAAE,eAAe,EAC/B,SAAS,EAAE,UAAU,EACrB,GAAG,EAAE,QAAQ,CAAC,GAAG,EACjB,MAAM,EAAE,MAAM;IAQV,aAAa,CAAC,eAAe,EAAE,eAAe;YAStC,KAAK;IAyBb,IAAI;IA2BV,IAAI,gBAAgB,uBAEnB;IAED;;OAEG;IACH,OAAO,KAAK,gBAAgB,GAE3B;IAED,OAAO,KAAK,SAAS,GAEpB;CACF"}
|
package/dist/core/Worker.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export class Worker {
|
|
2
|
-
lifecycle;
|
|
3
|
-
logger;
|
|
4
|
-
abortController = new AbortController();
|
|
5
|
-
batchProcessor;
|
|
6
|
-
sql;
|
|
7
|
-
constructor(batchProcessor, lifecycle, sql, logger) {
|
|
8
|
-
this.sql = sql;
|
|
9
|
-
this.lifecycle = lifecycle;
|
|
10
|
-
this.batchProcessor = batchProcessor;
|
|
11
|
-
this.logger = logger;
|
|
12
|
-
}
|
|
13
|
-
async startOnlyOnce(workerBootstrap) {
|
|
14
|
-
if (this.lifecycle.isRunning) {
|
|
15
|
-
this.logger.debug('Worker already running, ignoring start request');
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
await this.start(workerBootstrap);
|
|
19
|
-
}
|
|
20
|
-
async start(workerBootstrap) {
|
|
21
|
-
try {
|
|
22
|
-
await this.lifecycle.acknowledgeStart(workerBootstrap);
|
|
23
|
-
while (this.isMainLoopActive) {
|
|
24
|
-
try {
|
|
25
|
-
await this.lifecycle.sendHeartbeat();
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
this.logger.error(`Error sending heartbeat: ${error}`);
|
|
29
|
-
// Continue execution - a failed heartbeat shouldn't stop processing
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
await this.batchProcessor.processBatch();
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
this.logger.error(`Error processing batch: ${error}`);
|
|
36
|
-
// Continue to next iteration - failed batch shouldn't stop the worker
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
this.logger.error(`Error in worker main loop: ${error}`);
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async stop() {
|
|
46
|
-
// If the worker is already stopping or stopped, do nothing
|
|
47
|
-
if (this.lifecycle.isStopping || this.lifecycle.isStopped) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
this.lifecycle.transitionToStopping();
|
|
51
|
-
try {
|
|
52
|
-
this.logger.info('-> Stopped accepting new messages');
|
|
53
|
-
this.abortController.abort();
|
|
54
|
-
this.logger.info('-> Waiting for pending tasks to complete...');
|
|
55
|
-
await this.batchProcessor.awaitCompletion();
|
|
56
|
-
this.logger.info('-> Pending tasks completed!');
|
|
57
|
-
this.lifecycle.acknowledgeStop();
|
|
58
|
-
this.logger.info('-> Closing SQL connection...');
|
|
59
|
-
await this.sql.end();
|
|
60
|
-
this.logger.info('-> SQL connection closed!');
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
this.logger.info(`Error during worker stop: ${error}`);
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
get edgeFunctionName() {
|
|
68
|
-
return this.lifecycle.edgeFunctionName;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Returns true if worker state is Running and worker was not stopped
|
|
72
|
-
*/
|
|
73
|
-
get isMainLoopActive() {
|
|
74
|
-
return this.lifecycle.isRunning && !this.isAborted;
|
|
75
|
-
}
|
|
76
|
-
get isAborted() {
|
|
77
|
-
return this.abortController.signal.aborted;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Queries } from './Queries.js';
|
|
2
|
-
import type { Queue } from '../queue/Queue.js';
|
|
3
|
-
import type { ILifecycle, Json, WorkerBootstrap } from './types.js';
|
|
4
|
-
import type { Logger } from '../platform/types.js';
|
|
5
|
-
export interface LifecycleConfig {
|
|
6
|
-
queueName: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class WorkerLifecycle<IMessage extends Json> implements ILifecycle {
|
|
9
|
-
private workerState;
|
|
10
|
-
private heartbeat?;
|
|
11
|
-
private logger;
|
|
12
|
-
private queries;
|
|
13
|
-
private queue;
|
|
14
|
-
private workerRow?;
|
|
15
|
-
constructor(queries: Queries, queue: Queue<IMessage>, logger: Logger);
|
|
16
|
-
acknowledgeStart(workerBootstrap: WorkerBootstrap): Promise<void>;
|
|
17
|
-
acknowledgeStop(): void;
|
|
18
|
-
get edgeFunctionName(): string | undefined;
|
|
19
|
-
get queueName(): string;
|
|
20
|
-
sendHeartbeat(): Promise<void>;
|
|
21
|
-
get isRunning(): boolean;
|
|
22
|
-
get isStopping(): boolean;
|
|
23
|
-
get isStopped(): boolean;
|
|
24
|
-
transitionToStopping(): void;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=WorkerLifecycle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkerLifecycle.d.ts","sourceRoot":"","sources":["../../src/core/WorkerLifecycle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,EAAa,MAAM,YAAY,CAAC;AAE/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,eAAe,CAAC,QAAQ,SAAS,IAAI,CAAE,YAAW,UAAU;IACvE,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAY;gBAElB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM;IAO9D,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBvE,eAAe;IAyBf,IAAI,gBAAgB,uBAEnB;IAED,IAAI,SAAS,WAEZ;IAEK,aAAa;IAInB,IAAI,SAAS,YAEZ;IAED,IAAI,UAAU,YAEb;IAED,IAAI,SAAS,YAEZ;IAED,oBAAoB;CAGrB"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Heartbeat } from './Heartbeat.js';
|
|
2
|
-
import { States, WorkerState } from './WorkerState.js';
|
|
3
|
-
export class WorkerLifecycle {
|
|
4
|
-
workerState;
|
|
5
|
-
heartbeat;
|
|
6
|
-
logger;
|
|
7
|
-
queries;
|
|
8
|
-
queue;
|
|
9
|
-
workerRow;
|
|
10
|
-
constructor(queries, queue, logger) {
|
|
11
|
-
this.queries = queries;
|
|
12
|
-
this.queue = queue;
|
|
13
|
-
this.logger = logger;
|
|
14
|
-
this.workerState = new WorkerState(logger);
|
|
15
|
-
}
|
|
16
|
-
async acknowledgeStart(workerBootstrap) {
|
|
17
|
-
this.workerState.transitionTo(States.Starting);
|
|
18
|
-
this.logger.info(`Ensuring queue '${this.queue.queueName}' exists...`);
|
|
19
|
-
await this.queue.safeCreate();
|
|
20
|
-
this.workerRow = await this.queries.onWorkerStarted({
|
|
21
|
-
queueName: this.queueName,
|
|
22
|
-
...workerBootstrap,
|
|
23
|
-
});
|
|
24
|
-
this.heartbeat = new Heartbeat(5000, this.queries, this.workerRow, this.logger);
|
|
25
|
-
this.workerState.transitionTo(States.Running);
|
|
26
|
-
}
|
|
27
|
-
acknowledgeStop() {
|
|
28
|
-
this.workerState.transitionTo(States.Stopping);
|
|
29
|
-
if (!this.workerRow) {
|
|
30
|
-
throw new Error('Cannot stop worker: workerRow not set');
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
this.logger.debug('Acknowledging worker stop...');
|
|
34
|
-
// TODO: commented out because we can live without this
|
|
35
|
-
// but it is causing problems with DbHandler - workes does not have
|
|
36
|
-
// enough time to fire this query before hard-terimnated
|
|
37
|
-
// We can always check the heartbeat to see if it is still running
|
|
38
|
-
//
|
|
39
|
-
// await this.queries.onWorkerStopped(this.workerRow);
|
|
40
|
-
this.workerState.transitionTo(States.Stopped);
|
|
41
|
-
this.logger.debug('Worker stop acknowledged');
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
this.logger.debug(`Error acknowledging worker stop: ${error}`);
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
get edgeFunctionName() {
|
|
49
|
-
return this.workerRow?.function_name;
|
|
50
|
-
}
|
|
51
|
-
get queueName() {
|
|
52
|
-
return this.queue.queueName;
|
|
53
|
-
}
|
|
54
|
-
async sendHeartbeat() {
|
|
55
|
-
await this.heartbeat?.send();
|
|
56
|
-
}
|
|
57
|
-
get isRunning() {
|
|
58
|
-
return this.workerState.isRunning;
|
|
59
|
-
}
|
|
60
|
-
get isStopping() {
|
|
61
|
-
return this.workerState.isStopping;
|
|
62
|
-
}
|
|
63
|
-
get isStopped() {
|
|
64
|
-
return this.workerState.isStopped;
|
|
65
|
-
}
|
|
66
|
-
transitionToStopping() {
|
|
67
|
-
this.workerState.transitionTo(States.Stopping);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '../platform/types.js';
|
|
2
|
-
export declare enum States {
|
|
3
|
-
/** The worker has been created but has not yet started. */
|
|
4
|
-
Created = "created",
|
|
5
|
-
/** The worker is starting but has not yet started processing messages. */
|
|
6
|
-
Starting = "starting",
|
|
7
|
-
/** The worker is processing messages. */
|
|
8
|
-
Running = "running",
|
|
9
|
-
/** The worker stopped processing messages but is still releasing resources. */
|
|
10
|
-
Stopping = "stopping",
|
|
11
|
-
/** The worker has stopped processing messages and released resources
|
|
12
|
-
* and can be discarded. */
|
|
13
|
-
Stopped = "stopped"
|
|
14
|
-
}
|
|
15
|
-
export declare const Transitions: Record<States, States[]>;
|
|
16
|
-
export declare class TransitionError extends Error {
|
|
17
|
-
constructor(options: {
|
|
18
|
-
from: States;
|
|
19
|
-
to: States;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Represents the state of a worker and exposes method for doing allowed transitions
|
|
24
|
-
*/
|
|
25
|
-
export declare class WorkerState {
|
|
26
|
-
private logger;
|
|
27
|
-
private state;
|
|
28
|
-
constructor(logger: Logger);
|
|
29
|
-
get current(): States;
|
|
30
|
-
get isCreated(): boolean;
|
|
31
|
-
get isStarting(): boolean;
|
|
32
|
-
get isRunning(): boolean;
|
|
33
|
-
get isStopping(): boolean;
|
|
34
|
-
get isStopped(): boolean;
|
|
35
|
-
transitionTo(state: States): void;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=WorkerState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkerState.d.ts","sourceRoot":"","sources":["../../src/core/WorkerState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,oBAAY,MAAM;IAChB,2DAA2D;IAC3D,OAAO,YAAY;IAEnB,0EAA0E;IAC1E,QAAQ,aAAa;IAErB,yCAAyC;IACzC,OAAO,YAAY;IAEnB,+EAA+E;IAC/E,QAAQ,aAAa;IAErB;+BAC2B;IAC3B,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAMhD,CAAC;AAEF,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE;CAGlD;AAED;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAA0B;gBAE3B,MAAM,EAAE,MAAM;IAI1B,IAAI,OAAO,WAEV;IAED,IAAI,SAAS,YAEZ;IAED,IAAI,UAAU,YAEb;IAED,IAAI,SAAS,YAEZ;IAED,IAAI,UAAU,YAEb;IAED,IAAI,SAAS,YAEZ;IAED,YAAY,CAAC,KAAK,EAAE,MAAM;CAmB3B"}
|
package/dist/core/WorkerState.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
export var States;
|
|
2
|
-
(function (States) {
|
|
3
|
-
/** The worker has been created but has not yet started. */
|
|
4
|
-
States["Created"] = "created";
|
|
5
|
-
/** The worker is starting but has not yet started processing messages. */
|
|
6
|
-
States["Starting"] = "starting";
|
|
7
|
-
/** The worker is processing messages. */
|
|
8
|
-
States["Running"] = "running";
|
|
9
|
-
/** The worker stopped processing messages but is still releasing resources. */
|
|
10
|
-
States["Stopping"] = "stopping";
|
|
11
|
-
/** The worker has stopped processing messages and released resources
|
|
12
|
-
* and can be discarded. */
|
|
13
|
-
States["Stopped"] = "stopped";
|
|
14
|
-
})(States || (States = {}));
|
|
15
|
-
export const Transitions = {
|
|
16
|
-
[States.Created]: [States.Starting],
|
|
17
|
-
[States.Starting]: [States.Running],
|
|
18
|
-
[States.Running]: [States.Stopping],
|
|
19
|
-
[States.Stopping]: [States.Stopped],
|
|
20
|
-
[States.Stopped]: [], // Terminal state - no valid transitions from here
|
|
21
|
-
};
|
|
22
|
-
export class TransitionError extends Error {
|
|
23
|
-
constructor(options) {
|
|
24
|
-
super(`Cannot transition from ${options.from} to ${options.to}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Represents the state of a worker and exposes method for doing allowed transitions
|
|
29
|
-
*/
|
|
30
|
-
export class WorkerState {
|
|
31
|
-
logger;
|
|
32
|
-
state = States.Created;
|
|
33
|
-
constructor(logger) {
|
|
34
|
-
this.logger = logger;
|
|
35
|
-
}
|
|
36
|
-
get current() {
|
|
37
|
-
return this.state;
|
|
38
|
-
}
|
|
39
|
-
get isCreated() {
|
|
40
|
-
return this.state === States.Created;
|
|
41
|
-
}
|
|
42
|
-
get isStarting() {
|
|
43
|
-
return this.state === States.Starting;
|
|
44
|
-
}
|
|
45
|
-
get isRunning() {
|
|
46
|
-
return this.state === States.Running;
|
|
47
|
-
}
|
|
48
|
-
get isStopping() {
|
|
49
|
-
return this.state === States.Stopping;
|
|
50
|
-
}
|
|
51
|
-
get isStopped() {
|
|
52
|
-
return this.state === States.Stopped;
|
|
53
|
-
}
|
|
54
|
-
transitionTo(state) {
|
|
55
|
-
this.logger.debug(`[WorkerState] Starting transition to '${state}' (current state: ${this.state})`);
|
|
56
|
-
if (this.state === state) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (Transitions[this.state].includes(state)) {
|
|
60
|
-
this.state = state;
|
|
61
|
-
this.logger.debug(`[WorkerState] Transitioned to '${state}'`);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
throw new TransitionError({
|
|
65
|
-
from: this.state,
|
|
66
|
-
to: state,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
package/dist/core/types.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export type { Json } from '@pgflow/core';
|
|
2
|
-
export interface IPoller<IMessage> {
|
|
3
|
-
poll(): Promise<IMessage[]>;
|
|
4
|
-
}
|
|
5
|
-
export interface IExecutor {
|
|
6
|
-
get msgId(): number;
|
|
7
|
-
execute(): Promise<unknown>;
|
|
8
|
-
}
|
|
9
|
-
export interface IMessage {
|
|
10
|
-
msg_id: number;
|
|
11
|
-
}
|
|
12
|
-
export interface ILifecycle {
|
|
13
|
-
acknowledgeStart(workerBootstrap: WorkerBootstrap): Promise<void>;
|
|
14
|
-
acknowledgeStop(): void;
|
|
15
|
-
sendHeartbeat(): Promise<void>;
|
|
16
|
-
get edgeFunctionName(): string | undefined;
|
|
17
|
-
get queueName(): string;
|
|
18
|
-
get isRunning(): boolean;
|
|
19
|
-
get isStopping(): boolean;
|
|
20
|
-
get isStopped(): boolean;
|
|
21
|
-
transitionToStopping(): void;
|
|
22
|
-
}
|
|
23
|
-
export interface IBatchProcessor {
|
|
24
|
-
processBatch(): Promise<void>;
|
|
25
|
-
awaitCompletion(): Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
export type WorkerRow = {
|
|
28
|
-
last_heartbeat_at: string;
|
|
29
|
-
queue_name: string;
|
|
30
|
-
started_at: string;
|
|
31
|
-
stopped_at: string | null;
|
|
32
|
-
worker_id: string;
|
|
33
|
-
function_name: string;
|
|
34
|
-
};
|
|
35
|
-
export interface WorkerBootstrap {
|
|
36
|
-
edgeFunctionName: string;
|
|
37
|
-
workerId: string;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/core/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,WAAW,OAAO,CAAC,QAAQ;IAC/B,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,KAAK,IAAI,MAAM,CAAC;IACpB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,eAAe,IAAI,IAAI,CAAC;IACxB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/B,IAAI,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAAC;IAC3C,IAAI,SAAS,IAAI,MAAM,CAAC;IACxB,IAAI,SAAS,IAAI,OAAO,CAAC;IACzB,IAAI,UAAU,IAAI,OAAO,CAAC;IAC1B,IAAI,SAAS,IAAI,OAAO,CAAC;IAEzB,oBAAoB,IAAI,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/core/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Queries } from '../core/Queries.js';
|
|
2
|
-
import type { ILifecycle, WorkerBootstrap } from '../core/types.js';
|
|
3
|
-
import type { Logger } from '../platform/types.js';
|
|
4
|
-
import type { AnyFlow } from '@pgflow/dsl';
|
|
5
|
-
/**
|
|
6
|
-
* A specialized WorkerLifecycle for Flow-based workers that is aware of the Flow's step types
|
|
7
|
-
*/
|
|
8
|
-
export declare class FlowWorkerLifecycle<TFlow extends AnyFlow> implements ILifecycle {
|
|
9
|
-
private workerState;
|
|
10
|
-
private heartbeat?;
|
|
11
|
-
private logger;
|
|
12
|
-
private queries;
|
|
13
|
-
private workerRow?;
|
|
14
|
-
private flow;
|
|
15
|
-
constructor(queries: Queries, flow: TFlow, logger: Logger);
|
|
16
|
-
acknowledgeStart(workerBootstrap: WorkerBootstrap): Promise<void>;
|
|
17
|
-
acknowledgeStop(): void;
|
|
18
|
-
get edgeFunctionName(): string | undefined;
|
|
19
|
-
get queueName(): string;
|
|
20
|
-
sendHeartbeat(): Promise<void>;
|
|
21
|
-
get isRunning(): boolean;
|
|
22
|
-
get isStopping(): boolean;
|
|
23
|
-
get isStopped(): boolean;
|
|
24
|
-
transitionToStopping(): void;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=FlowWorkerLifecycle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FlowWorkerLifecycle.d.ts","sourceRoot":"","sources":["../../src/flow/FlowWorkerLifecycle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAa,MAAM,kBAAkB,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;GAEG;AACH,qBAAa,mBAAmB,CAAC,KAAK,SAAS,OAAO,CAAE,YAAW,UAAU;IAC3E,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,IAAI,CAAQ;gBAER,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM;IAOnD,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBvE,eAAe;IAiBf,IAAI,gBAAgB,uBAEnB;IAED,IAAI,SAAS,WAEZ;IAEK,aAAa;IAInB,IAAI,SAAS,YAEZ;IAED,IAAI,UAAU,YAEb;IAED,IAAI,SAAS,YAEZ;IAED,oBAAoB;CAGrB"}
|