@blazetrails/solid-queue 0.0.0-stage → 0.1.0-alpha0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +14 -2
- package/dist/active-job/batch-id.d.ts +37 -0
- package/dist/active-job/batch-id.js +45 -0
- package/dist/active-job/batch-id.js.map +1 -0
- package/dist/active-job/concurrency-controls.d.ts +51 -0
- package/dist/active-job/concurrency-controls.js +77 -0
- package/dist/active-job/concurrency-controls.js.map +1 -0
- package/dist/active-job/queue-adapters/solid-queue-adapter.d.ts +19 -0
- package/dist/active-job/queue-adapters/solid-queue-adapter.js +36 -0
- package/dist/active-job/queue-adapters/solid-queue-adapter.js.map +1 -0
- package/dist/app-executor.d.ts +10 -0
- package/dist/app-executor.js +31 -0
- package/dist/app-executor.js.map +1 -0
- package/dist/async-supervisor.d.ts +21 -0
- package/dist/async-supervisor.js +78 -0
- package/dist/async-supervisor.js.map +1 -0
- package/dist/batch/callbacks.d.ts +28 -0
- package/dist/batch/callbacks.js +70 -0
- package/dist/batch/callbacks.js.map +1 -0
- package/dist/batch/clearable.d.ts +14 -0
- package/dist/batch/clearable.js +27 -0
- package/dist/batch/clearable.js.map +1 -0
- package/dist/batch/status.d.ts +24 -0
- package/dist/batch/status.js +66 -0
- package/dist/batch/status.js.map +1 -0
- package/dist/batch/sweepable.d.ts +20 -0
- package/dist/batch/sweepable.js +64 -0
- package/dist/batch/sweepable.js.map +1 -0
- package/dist/batch-execution.d.ts +15 -0
- package/dist/batch-execution.js +69 -0
- package/dist/batch-execution.js.map +1 -0
- package/dist/batch.d.ts +106 -0
- package/dist/batch.js +154 -0
- package/dist/batch.js.map +1 -0
- package/dist/blocked-execution.d.ts +23 -0
- package/dist/blocked-execution.js +88 -0
- package/dist/blocked-execution.js.map +1 -0
- package/dist/claimed-execution.d.ts +44 -0
- package/dist/claimed-execution.js +161 -0
- package/dist/claimed-execution.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +58 -0
- package/dist/cli.js.map +1 -0
- package/dist/configuration.d.ts +123 -0
- package/dist/configuration.js +361 -0
- package/dist/configuration.js.map +1 -0
- package/dist/constants.generated.d.ts +2 -0
- package/dist/constants.generated.js +179 -0
- package/dist/constants.generated.js.map +1 -0
- package/dist/dispatcher/concurrency-maintenance.d.ts +5 -0
- package/dist/dispatcher/concurrency-maintenance.js +7 -0
- package/dist/dispatcher/concurrency-maintenance.js.map +1 -0
- package/dist/dispatcher/maintenance.d.ts +30 -0
- package/dist/dispatcher/maintenance.js +87 -0
- package/dist/dispatcher/maintenance.js.map +1 -0
- package/dist/dispatcher.d.ts +40 -0
- package/dist/dispatcher.js +68 -0
- package/dist/dispatcher.js.map +1 -0
- package/dist/engine.d.ts +17 -0
- package/dist/engine.js +59 -0
- package/dist/engine.js.map +1 -0
- package/dist/execution/dispatching.d.ts +10 -0
- package/dist/execution/dispatching.js +18 -0
- package/dist/execution/dispatching.js.map +1 -0
- package/dist/execution/job-attributes.d.ts +17 -0
- package/dist/execution/job-attributes.js +35 -0
- package/dist/execution/job-attributes.js.map +1 -0
- package/dist/execution.d.ts +38 -0
- package/dist/execution.js +84 -0
- package/dist/execution.js.map +1 -0
- package/dist/failed-execution/batchable.d.ts +9 -0
- package/dist/failed-execution/batchable.js +32 -0
- package/dist/failed-execution/batchable.js.map +1 -0
- package/dist/failed-execution.d.ts +37 -0
- package/dist/failed-execution.js +120 -0
- package/dist/failed-execution.js.map +1 -0
- package/dist/fiber-pool.d.ts +47 -0
- package/dist/fiber-pool.js +135 -0
- package/dist/fiber-pool.js.map +1 -0
- package/dist/fork-supervisor.d.ts +24 -0
- package/dist/fork-supervisor.js +95 -0
- package/dist/fork-supervisor.js.map +1 -0
- package/dist/generators/solid-queue/install/install-generator.d.ts +6 -0
- package/dist/generators/solid-queue/install/install-generator.js +27 -0
- package/dist/generators/solid-queue/install/install-generator.js.map +1 -0
- package/dist/generators/solid-queue/install/templates/bin/jobs.tt +6 -0
- package/dist/generators/solid-queue/install/templates/bin/jobs.tt.js +12 -0
- package/dist/generators/solid-queue/install/templates/config/queue.yml.tt +18 -0
- package/dist/generators/solid-queue/install/templates/config/queue.yml.tt.js +12 -0
- package/dist/generators/solid-queue/install/templates/config/recurring.yml.tt +10 -0
- package/dist/generators/solid-queue/install/templates/config/recurring.yml.tt.js +12 -0
- package/dist/generators/solid-queue/install/templates/db/queue_schema.ts.tt +218 -0
- package/dist/generators/solid-queue/install/templates/db/queue_schema.ts.tt.js +12 -0
- package/dist/generators/solid-queue/update/templates/db/add_batches_to_solid_queue.ts.tt +41 -0
- package/dist/generators/solid-queue/update/templates/db/add_batches_to_solid_queue.ts.tt.js +12 -0
- package/dist/generators/solid-queue/update/update-generator.d.ts +8 -0
- package/dist/generators/solid-queue/update/update-generator.js +28 -0
- package/dist/generators/solid-queue/update/update-generator.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/job/batchable.d.ts +25 -0
- package/dist/job/batchable.js +52 -0
- package/dist/job/batchable.js.map +1 -0
- package/dist/job/clearable.d.ts +18 -0
- package/dist/job/clearable.js +30 -0
- package/dist/job/clearable.js.map +1 -0
- package/dist/job/concurrency-controls.d.ts +60 -0
- package/dist/job/concurrency-controls.js +121 -0
- package/dist/job/concurrency-controls.js.map +1 -0
- package/dist/job/executable.d.ts +53 -0
- package/dist/job/executable.js +123 -0
- package/dist/job/executable.js.map +1 -0
- package/dist/job/recurrable.d.ts +5 -0
- package/dist/job/recurrable.js +10 -0
- package/dist/job/recurrable.js.map +1 -0
- package/dist/job/retryable.d.ts +18 -0
- package/dist/job/retryable.js +43 -0
- package/dist/job/retryable.js.map +1 -0
- package/dist/job/schedulable.d.ts +26 -0
- package/dist/job/schedulable.js +41 -0
- package/dist/job/schedulable.js.map +1 -0
- package/dist/job.d.ts +115 -0
- package/dist/job.js +111 -0
- package/dist/job.js.map +1 -0
- package/dist/lifecycle-hooks.d.ts +37 -0
- package/dist/lifecycle-hooks.js +50 -0
- package/dist/lifecycle-hooks.js.map +1 -0
- package/dist/log-subscriber.d.ts +37 -0
- package/dist/log-subscriber.js +262 -0
- package/dist/log-subscriber.js.map +1 -0
- package/dist/pause.d.ts +5 -0
- package/dist/pause.js +9 -0
- package/dist/pause.js.map +1 -0
- package/dist/pool.d.ts +48 -0
- package/dist/pool.js +100 -0
- package/dist/pool.js.map +1 -0
- package/dist/process/executor.d.ts +17 -0
- package/dist/process/executor.js +27 -0
- package/dist/process/executor.js.map +1 -0
- package/dist/process/prunable.d.ts +13 -0
- package/dist/process/prunable.js +35 -0
- package/dist/process/prunable.js.map +1 -0
- package/dist/process.d.ts +32 -0
- package/dist/process.js +77 -0
- package/dist/process.js.map +1 -0
- package/dist/processes/base.d.ts +37 -0
- package/dist/processes/base.js +48 -0
- package/dist/processes/base.js.map +1 -0
- package/dist/processes/callbacks.d.ts +15 -0
- package/dist/processes/callbacks.js +11 -0
- package/dist/processes/callbacks.js.map +1 -0
- package/dist/processes/fork-entry.d.ts +2 -0
- package/dist/processes/fork-entry.js +24 -0
- package/dist/processes/fork-entry.js.map +1 -0
- package/dist/processes/interruptible.d.ts +19 -0
- package/dist/processes/interruptible.js +32 -0
- package/dist/processes/interruptible.js.map +1 -0
- package/dist/processes/poller.d.ts +30 -0
- package/dist/processes/poller.js +64 -0
- package/dist/processes/poller.js.map +1 -0
- package/dist/processes/process-exit-error.d.ts +12 -0
- package/dist/processes/process-exit-error.js +15 -0
- package/dist/processes/process-exit-error.js.map +1 -0
- package/dist/processes/process-missing-error.d.ts +5 -0
- package/dist/processes/process-missing-error.js +7 -0
- package/dist/processes/process-missing-error.js.map +1 -0
- package/dist/processes/process-pruned-error.d.ts +5 -0
- package/dist/processes/process-pruned-error.js +7 -0
- package/dist/processes/process-pruned-error.js.map +1 -0
- package/dist/processes/procline.d.ts +4 -0
- package/dist/processes/procline.js +9 -0
- package/dist/processes/procline.js.map +1 -0
- package/dist/processes/registrable.d.ts +48 -0
- package/dist/processes/registrable.js +81 -0
- package/dist/processes/registrable.js.map +1 -0
- package/dist/processes/runnable.d.ts +92 -0
- package/dist/processes/runnable.js +181 -0
- package/dist/processes/runnable.js.map +1 -0
- package/dist/processes/supervised.d.ts +39 -0
- package/dist/processes/supervised.js +45 -0
- package/dist/processes/supervised.js.map +1 -0
- package/dist/processes/thread-terminated-error.d.ts +5 -0
- package/dist/processes/thread-terminated-error.js +7 -0
- package/dist/processes/thread-terminated-error.js.map +1 -0
- package/dist/processes/unrecoverable-error.d.ts +4 -0
- package/dist/processes/unrecoverable-error.js +4 -0
- package/dist/processes/unrecoverable-error.js.map +1 -0
- package/dist/queue-selector.d.ts +40 -0
- package/dist/queue-selector.js +109 -0
- package/dist/queue-selector.js.map +1 -0
- package/dist/queue.d.ts +19 -0
- package/dist/queue.js +54 -0
- package/dist/queue.js.map +1 -0
- package/dist/ready-execution.d.ts +17 -0
- package/dist/ready-execution.js +64 -0
- package/dist/ready-execution.js.map +1 -0
- package/dist/record/distinct-values.d.ts +16 -0
- package/dist/record/distinct-values.js +46 -0
- package/dist/record/distinct-values.js.map +1 -0
- package/dist/record.d.ts +18 -0
- package/dist/record.js +41 -0
- package/dist/record.js.map +1 -0
- package/dist/recurring-execution.d.ts +19 -0
- package/dist/recurring-execution.js +54 -0
- package/dist/recurring-execution.js.map +1 -0
- package/dist/recurring-job.d.ts +5 -0
- package/dist/recurring-job.js +10 -0
- package/dist/recurring-job.js.map +1 -0
- package/dist/recurring-task/arguments.d.ts +5 -0
- package/dist/recurring-task/arguments.js +12 -0
- package/dist/recurring-task/arguments.js.map +1 -0
- package/dist/recurring-task.d.ts +90 -0
- package/dist/recurring-task.js +240 -0
- package/dist/recurring-task.js.map +1 -0
- package/dist/scheduled-execution.d.ts +17 -0
- package/dist/scheduled-execution.js +35 -0
- package/dist/scheduled-execution.js.map +1 -0
- package/dist/scheduler/recurring-schedule.d.ts +60 -0
- package/dist/scheduler/recurring-schedule.js +141 -0
- package/dist/scheduler/recurring-schedule.js.map +1 -0
- package/dist/scheduler.d.ts +51 -0
- package/dist/scheduler.js +96 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/semaphore.d.ts +44 -0
- package/dist/semaphore.js +119 -0
- package/dist/semaphore.js.map +1 -0
- package/dist/solid-queue.d.ts +75 -0
- package/dist/solid-queue.js +89 -0
- package/dist/solid-queue.js.map +1 -0
- package/dist/supervisor/maintenance.d.ts +39 -0
- package/dist/supervisor/maintenance.js +55 -0
- package/dist/supervisor/maintenance.js.map +1 -0
- package/dist/supervisor/pidfile.d.ts +23 -0
- package/dist/supervisor/pidfile.js +73 -0
- package/dist/supervisor/pidfile.js.map +1 -0
- package/dist/supervisor/pidfiled.d.ts +14 -0
- package/dist/supervisor/pidfiled.js +26 -0
- package/dist/supervisor/pidfiled.js.map +1 -0
- package/dist/supervisor/signals.d.ts +43 -0
- package/dist/supervisor/signals.js +70 -0
- package/dist/supervisor/signals.js.map +1 -0
- package/dist/supervisor.d.ts +94 -0
- package/dist/supervisor.js +176 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/tasks.d.ts +2 -0
- package/dist/tasks.js +26 -0
- package/dist/tasks.js.map +1 -0
- package/dist/thread-pool.d.ts +13 -0
- package/dist/thread-pool.js +43 -0
- package/dist/thread-pool.js.map +1 -0
- package/dist/timer.d.ts +6 -0
- package/dist/timer.js +26 -0
- package/dist/timer.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/worker.d.ts +37 -0
- package/dist/worker.js +74 -0
- package/dist/worker.js.map +1 -0
- package/package.json +65 -3
package/dist/pool.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { camelize, demodulize, include, underscore } from "@blazetrails/activesupport";
|
|
2
|
+
import { Mutex, NotImplementedError, RuntimeError, constGet, rbModName, } from "@blazetrails/ruby-compat";
|
|
3
|
+
import { AppExecutor } from "./app-executor.js";
|
|
4
|
+
import { UnrecoverableError } from "./processes/unrecoverable-error.js";
|
|
5
|
+
import { SolidQueue } from "./solid-queue.js";
|
|
6
|
+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- see the interface below. */
|
|
7
|
+
export class Pool {
|
|
8
|
+
static {
|
|
9
|
+
include(this, AppExecutor);
|
|
10
|
+
}
|
|
11
|
+
static build({ type, size, onIdle = null, onUnrecoverableError = null, }) {
|
|
12
|
+
const klass = constGet(SolidQueue, `${camelize(type)}Pool`);
|
|
13
|
+
return new klass(size, { onIdle: onIdle, onUnrecoverableError: onUnrecoverableError });
|
|
14
|
+
}
|
|
15
|
+
size;
|
|
16
|
+
_onIdle;
|
|
17
|
+
_onUnrecoverableError;
|
|
18
|
+
_availableCapacity;
|
|
19
|
+
_mutex;
|
|
20
|
+
constructor(size, { onIdle = null, onUnrecoverableError = null } = {}) {
|
|
21
|
+
this.size = size;
|
|
22
|
+
this._onIdle = onIdle;
|
|
23
|
+
this._onUnrecoverableError = onUnrecoverableError;
|
|
24
|
+
this._availableCapacity = size;
|
|
25
|
+
this._mutex = new Mutex();
|
|
26
|
+
}
|
|
27
|
+
get type() {
|
|
28
|
+
const name = demodulize(rbModName(this.constructor));
|
|
29
|
+
return underscore(name.endsWith("Pool") ? name.slice(0, -"Pool".length) : name);
|
|
30
|
+
}
|
|
31
|
+
async post(execution) {
|
|
32
|
+
await this.reserveCapacityBang();
|
|
33
|
+
try {
|
|
34
|
+
await this.schedule(execution);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
await this.restoreCapacity();
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async availableCapacity() {
|
|
42
|
+
return await this.mutex.synchronize(() => this._availableCapacity);
|
|
43
|
+
}
|
|
44
|
+
async isIdle() {
|
|
45
|
+
return (await this.availableCapacity()) > 0;
|
|
46
|
+
}
|
|
47
|
+
/** @internal */
|
|
48
|
+
get mutex() {
|
|
49
|
+
return this._mutex;
|
|
50
|
+
}
|
|
51
|
+
/** @internal */
|
|
52
|
+
get onIdle() {
|
|
53
|
+
return this._onIdle;
|
|
54
|
+
}
|
|
55
|
+
/** @internal */
|
|
56
|
+
get onUnrecoverableError() {
|
|
57
|
+
return this._onUnrecoverableError;
|
|
58
|
+
}
|
|
59
|
+
/** @internal */
|
|
60
|
+
schedule(_execution) {
|
|
61
|
+
throw new NotImplementedError();
|
|
62
|
+
}
|
|
63
|
+
/** @internal */
|
|
64
|
+
async performExecution(execution) {
|
|
65
|
+
try {
|
|
66
|
+
await this.wrapInAppExecutor(() => execution.perform());
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
this.handleUnrecoverableError(error);
|
|
70
|
+
this.handleThreadError(error);
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
await this.restoreCapacity();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** @internal */
|
|
77
|
+
handleUnrecoverableError(error) {
|
|
78
|
+
if (!(error instanceof UnrecoverableError))
|
|
79
|
+
return;
|
|
80
|
+
this.onUnrecoverableError?.();
|
|
81
|
+
}
|
|
82
|
+
/** @internal */
|
|
83
|
+
async reserveCapacityBang() {
|
|
84
|
+
await this.mutex.synchronize(() => {
|
|
85
|
+
if (this._availableCapacity <= 0)
|
|
86
|
+
throw new RuntimeError("Execution pool is at capacity");
|
|
87
|
+
this._availableCapacity -= 1;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** @internal */
|
|
91
|
+
async restoreCapacity() {
|
|
92
|
+
const shouldNotify = await this.mutex.synchronize(() => {
|
|
93
|
+
this._availableCapacity += 1;
|
|
94
|
+
return this._availableCapacity > 0;
|
|
95
|
+
});
|
|
96
|
+
if (shouldNotify)
|
|
97
|
+
await this.onIdle?.();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=pool.js.map
|
package/dist/pool.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
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azetrails/activerecord";
|
|
3
|
+
import type { ClaimedExecution } from "../claimed-execution.js";
|
|
4
|
+
interface ExecutorHost {
|
|
5
|
+
kind: string;
|
|
6
|
+
claimedExecutions: Relation<ClaimedExecution> & typeof ClaimedExecution;
|
|
7
|
+
isClaimsExecutions(): boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class Executor {
|
|
10
|
+
static readonly [classModule] = true;
|
|
11
|
+
failAllClaimedExecutionsWith(this: ExecutorHost, error: Error): Promise<unknown>;
|
|
12
|
+
releaseAllClaimedExecutions(this: ExecutorHost): Promise<unknown>;
|
|
13
|
+
/** @internal */
|
|
14
|
+
isClaimsExecutions(this: ExecutorHost): boolean;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Concern, extend } from "@blazetrails/activesupport";
|
|
2
|
+
import { classModule } from "@blazetrails/ruby-compat";
|
|
3
|
+
export class Executor {
|
|
4
|
+
static [classModule] = true;
|
|
5
|
+
async failAllClaimedExecutionsWith(error) {
|
|
6
|
+
if (this.isClaimsExecutions()) {
|
|
7
|
+
return await this.claimedExecutions.failAllWith(error);
|
|
8
|
+
}
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
async releaseAllClaimedExecutions() {
|
|
12
|
+
if (this.isClaimsExecutions()) {
|
|
13
|
+
return await this.claimedExecutions.releaseAll();
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/** @internal */
|
|
18
|
+
isClaimsExecutions() {
|
|
19
|
+
return this.kind === "Worker";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
extend(Executor, Concern);
|
|
23
|
+
Executor.included(null, function () {
|
|
24
|
+
this.hasMany("claimedExecutions");
|
|
25
|
+
this.afterDestroy(":releaseAllClaimedExecutions");
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../lib/process/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAWvD,MAAM,OAAO,QAAQ;IACnB,MAAM,CAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAErC,KAAK,CAAC,4BAA4B,CAAqB,KAAY;QACjE,IAAI,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;YAC9B,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,2BAA2B;QAC/B,IAAI,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;YAC9B,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IAChB,kBAAkB;QAChB,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;IAChC,CAAC;CACF;AACD,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAExB,QAGD,CAAC,QAAQ,CAAC,IAAI,EAAE;IACf,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAElC,IAAI,CAAC,YAAY,CAAC,8BAA8B,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { classModule } from "@blazetrails/ruby-compat";
|
|
2
|
+
import type { Process } from "../process.js";
|
|
3
|
+
export declare class ClassMethods {
|
|
4
|
+
static prune(this: typeof Process, { excluding }?: {
|
|
5
|
+
excluding?: Process | null;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class Prunable {
|
|
9
|
+
static readonly [classModule] = true;
|
|
10
|
+
static ClassMethods: typeof ClassMethods;
|
|
11
|
+
prune(this: Process): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=prunable.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Concern, extend } from "@blazetrails/activesupport";
|
|
2
|
+
import { Range, classModule } from "@blazetrails/ruby-compat";
|
|
3
|
+
import { ProcessPrunedError } from "../processes/process-pruned-error.js";
|
|
4
|
+
import { SolidQueue } from "../solid-queue.js";
|
|
5
|
+
export class ClassMethods {
|
|
6
|
+
static async prune({ excluding = null } = {}) {
|
|
7
|
+
await SolidQueue.instrument("prune_processes", { size: 0 }, async (payload) => {
|
|
8
|
+
for await (const batch of this.prunable().excluding(excluding)
|
|
9
|
+
.nonBlockingLock()
|
|
10
|
+
.findInBatches({ batchSize: 50 })) {
|
|
11
|
+
payload.size += batch.length;
|
|
12
|
+
for (const process of batch)
|
|
13
|
+
await process.prune();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class Prunable {
|
|
19
|
+
static [classModule] = true;
|
|
20
|
+
async prune() {
|
|
21
|
+
const error = new ProcessPrunedError(this.last_heartbeat_at);
|
|
22
|
+
await this.failAllClaimedExecutionsWith(error);
|
|
23
|
+
await this.deregister({ pruned: true });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
extend(Prunable, Concern);
|
|
27
|
+
Object.defineProperty(Prunable, "ClassMethods", { value: ClassMethods });
|
|
28
|
+
Prunable.included(null, function () {
|
|
29
|
+
this.scope("prunable", function () {
|
|
30
|
+
return this.where({
|
|
31
|
+
last_heartbeat_at: new Range(null, SolidQueue.processAliveThreshold.ago()),
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=prunable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prunable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,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1B,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AAEvE,QAGD,CAAC,QAAQ,CAAC,IAAI,EAAE;IACf,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC;YAChB,iBAAiB,EAAE,IAAI,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,qBAAqB,CAAC,GAAG,EAAE,CAAC;SAC3E,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Relation } from "@blazetrails/activerecord";
|
|
2
|
+
import { type HashWithIndifferentAccess } from "@blazetrails/activesupport";
|
|
3
|
+
import { Time } from "@blazetrails/date";
|
|
4
|
+
import { Record } from "./record.js";
|
|
5
|
+
import { Executor } from "./process/executor.js";
|
|
6
|
+
import { Prunable, type ClassMethods as PrunableClassMethods } from "./process/prunable.js";
|
|
7
|
+
export declare class Process extends Record {
|
|
8
|
+
kind: string;
|
|
9
|
+
name: string;
|
|
10
|
+
pid: number;
|
|
11
|
+
hostname: string | null;
|
|
12
|
+
metadata: HashWithIndifferentAccess;
|
|
13
|
+
last_heartbeat_at: Time;
|
|
14
|
+
supervisor_id: unknown;
|
|
15
|
+
supervisor: Promise<Process | null>;
|
|
16
|
+
supervisees: Relation<Process>;
|
|
17
|
+
failAllClaimedExecutionsWith: (error: Error) => Promise<unknown>;
|
|
18
|
+
releaseAllClaimedExecutions: typeof Executor.prototype.releaseAllClaimedExecutions;
|
|
19
|
+
prune: typeof Prunable.prototype.prune;
|
|
20
|
+
static prunable: () => Relation<Process>;
|
|
21
|
+
static prune: typeof PrunableClassMethods.prune;
|
|
22
|
+
static register(attributes: {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}): Promise<Process>;
|
|
25
|
+
heartbeat(): Promise<void>;
|
|
26
|
+
deregister({ pruned }?: {
|
|
27
|
+
pruned?: boolean;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
/** @internal */
|
|
30
|
+
private isSupervised;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=process.d.ts.map
|
package/dist/process.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { StandardError, constSet } from "@blazetrails/ruby-compat";
|
|
2
|
+
import { include, isPresent } from "@blazetrails/activesupport";
|
|
3
|
+
import { Time } from "@blazetrails/date";
|
|
4
|
+
import { Record } from "./record.js";
|
|
5
|
+
import { SolidQueue } from "./solid-queue.js";
|
|
6
|
+
import { Executor } from "./process/executor.js";
|
|
7
|
+
import { Prunable } from "./process/prunable.js";
|
|
8
|
+
export class Process extends Record {
|
|
9
|
+
static {
|
|
10
|
+
constSet(SolidQueue, "Process", this);
|
|
11
|
+
include(this, Executor);
|
|
12
|
+
include(this, Prunable);
|
|
13
|
+
this.belongsTo("supervisor", {
|
|
14
|
+
className: "Process",
|
|
15
|
+
optional: true,
|
|
16
|
+
inverseOf: "supervisees",
|
|
17
|
+
});
|
|
18
|
+
this.hasMany("supervisees", {
|
|
19
|
+
className: "Process",
|
|
20
|
+
inverseOf: "supervisor",
|
|
21
|
+
foreignKey: "supervisor_id",
|
|
22
|
+
});
|
|
23
|
+
this.store("metadata", { coder: JSON });
|
|
24
|
+
}
|
|
25
|
+
static async register(attributes) {
|
|
26
|
+
return await SolidQueue.instrument("register_process", attributes, async (payload) => {
|
|
27
|
+
try {
|
|
28
|
+
const process = await this.createBang({
|
|
29
|
+
...attributes,
|
|
30
|
+
last_heartbeat_at: Time.current(),
|
|
31
|
+
});
|
|
32
|
+
payload.process_id = process.id;
|
|
33
|
+
return process;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
payload.error = error;
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async heartbeat() {
|
|
42
|
+
try {
|
|
43
|
+
this.restoreAttributes();
|
|
44
|
+
await this.withLock(async () => {
|
|
45
|
+
await this.touch("last_heartbeat_at");
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (!(error instanceof StandardError))
|
|
50
|
+
throw error;
|
|
51
|
+
this.restoreAttributes();
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async deregister({ pruned = false } = {}) {
|
|
56
|
+
await SolidQueue.instrument("deregister_process", { process: this, pruned: pruned }, async (payload) => {
|
|
57
|
+
try {
|
|
58
|
+
await this.destroyBang();
|
|
59
|
+
if (!(this.isSupervised() || pruned)) {
|
|
60
|
+
for (const supervisee of await this.supervisees.toArray()) {
|
|
61
|
+
await supervisee.deregister();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
payload.error = error;
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** @internal */
|
|
72
|
+
isSupervised() {
|
|
73
|
+
return isPresent(this.supervisor_id);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
SolidQueue.Process = Process;
|
|
77
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../lib/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAkC,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,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ethods } from "./callbacks.js";
|
|
2
|
+
import type { Process as ProcessRecord } from "../process.js";
|
|
3
|
+
export declare class Base {
|
|
4
|
+
static beforeBoot: CallbacksClassMethods["beforeBoot"];
|
|
5
|
+
static aroundBoot: CallbacksClassMethods["aroundBoot"];
|
|
6
|
+
static afterBoot: CallbacksClassMethods["afterBoot"];
|
|
7
|
+
static beforeShutdown: CallbacksClassMethods["beforeShutdown"];
|
|
8
|
+
static aroundShutdown: CallbacksClassMethods["aroundShutdown"];
|
|
9
|
+
static afterShutdown: CallbacksClassMethods["afterShutdown"];
|
|
10
|
+
readonly name: string;
|
|
11
|
+
protected _stopped: boolean;
|
|
12
|
+
private _hostname?;
|
|
13
|
+
private _pid?;
|
|
14
|
+
constructor(..._args: unknown[]);
|
|
15
|
+
get kind(): string;
|
|
16
|
+
get hostname(): string;
|
|
17
|
+
get pid(): number;
|
|
18
|
+
metadata(): Promise<Record<string, unknown>>;
|
|
19
|
+
stop(): Promise<void>;
|
|
20
|
+
/** @internal */
|
|
21
|
+
generateName(): string;
|
|
22
|
+
/** @internal */
|
|
23
|
+
isStopped(): boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface Base {
|
|
26
|
+
process: ProcessRecord | null;
|
|
27
|
+
readonly processId: unknown;
|
|
28
|
+
runCallbacks(kind: string, block?: () => unknown): Promise<unknown>;
|
|
29
|
+
wrapInAppExecutor<T>(block: () => T): T;
|
|
30
|
+
handleThreadError(error: unknown): void;
|
|
31
|
+
procline(string: string): void;
|
|
32
|
+
wakeUp(): Promise<void>;
|
|
33
|
+
interruptibleSleep(time: unknown): Promise<null>;
|
|
34
|
+
isRegistered(): boolean;
|
|
35
|
+
register(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { demodulize, include } from "@blazetrails/activesupport";
|
|
2
|
+
import { Process, SecureRandom, Socket, rbModName } from "@blazetrails/ruby-compat";
|
|
3
|
+
import { AppExecutor } from "../app-executor.js";
|
|
4
|
+
import { Callbacks } from "./callbacks.js";
|
|
5
|
+
import { Procline } from "./procline.js";
|
|
6
|
+
import { Registrable } from "./registrable.js";
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging -- Ruby `include` of the process concerns (`processes/base.rb:6-7`). */
|
|
8
|
+
export class Base {
|
|
9
|
+
static {
|
|
10
|
+
include(this, Callbacks);
|
|
11
|
+
include(this, AppExecutor);
|
|
12
|
+
include(this, Registrable);
|
|
13
|
+
include(this, Procline);
|
|
14
|
+
}
|
|
15
|
+
name;
|
|
16
|
+
_stopped;
|
|
17
|
+
_hostname;
|
|
18
|
+
_pid;
|
|
19
|
+
constructor(..._args) {
|
|
20
|
+
this.name = this.generateName();
|
|
21
|
+
this._stopped = false;
|
|
22
|
+
}
|
|
23
|
+
get kind() {
|
|
24
|
+
return demodulize(rbModName(this.constructor));
|
|
25
|
+
}
|
|
26
|
+
get hostname() {
|
|
27
|
+
return (this._hostname ??= Socket.gethostname());
|
|
28
|
+
}
|
|
29
|
+
get pid() {
|
|
30
|
+
return (this._pid ??= Process.pid);
|
|
31
|
+
}
|
|
32
|
+
async metadata() {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
async stop() {
|
|
36
|
+
this._stopped = true;
|
|
37
|
+
}
|
|
38
|
+
/** @internal */
|
|
39
|
+
generateName() {
|
|
40
|
+
return [this.kind.toLowerCase(), SecureRandom.hex(10)].join("-");
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
isStopped() {
|
|
44
|
+
return this._stopped;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/* eslint-enable @typescript-eslint/no-unsafe-declaration-merging */
|
|
48
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../lib/processes/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,E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ACvB,CAAC;IAED,gBAAgB;IAChB,YAAY;QACV,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,CAAC;IAED,gBAAgB;IAChB,SAAS;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAcD,oEAAoE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { included } from "@blazetrails/activesupport";
|
|
2
|
+
import { classModule } from "@blazetrails/ruby-compat";
|
|
3
|
+
export declare class Callbacks {
|
|
4
|
+
static readonly [classModule] = true;
|
|
5
|
+
static [included](base: object): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class ClassMethods {
|
|
8
|
+
beforeBoot: (...callbacks: unknown[]) => void;
|
|
9
|
+
aroundBoot: (...callbacks: unknown[]) => void;
|
|
10
|
+
afterBoot: (...callbacks: unknown[]) => void;
|
|
11
|
+
beforeShutdown: (...callbacks: unknown[]) => void;
|
|
12
|
+
aroundShutdown: (...callbacks: unknown[]) => void;
|
|
13
|
+
afterShutdown: (...callbacks: unknown[]) => void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=callbacks.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Callbacks as ActiveModelCallbacks } from "@blazetrails/activemodel";
|
|
2
|
+
import { extend, included } from "@blazetrails/activesupport";
|
|
3
|
+
import { classModule } from "@blazetrails/ruby-compat";
|
|
4
|
+
export class Callbacks {
|
|
5
|
+
static [classModule] = true;
|
|
6
|
+
static [included](base) {
|
|
7
|
+
extend(base, ActiveModelCallbacks);
|
|
8
|
+
base.defineModelCallbacks("boot", "shutdown");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=callbacks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../lib/processes/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,MAAM,OAAO,SAAS;IACpB,MAAM,CAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAErC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAY;QAC5B,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAClC,IAAoC,CAAC,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjF,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TopLevel, constGet, exitBang, rbForkPayload, rbForkedPipe, rbModName, } from "@blazetrails/ruby-compat";
|
|
2
|
+
import { Process, RecurringTask, Scheduler } from "../index.js";
|
|
3
|
+
import { ForkGuard } from "./runnable.js";
|
|
4
|
+
const { boot, processClass, attributes, name, supervisorId } = rbForkPayload();
|
|
5
|
+
await import(boot);
|
|
6
|
+
if (processClass === rbModName(Scheduler)) {
|
|
7
|
+
await RecurringTask.loadSchema();
|
|
8
|
+
attributes.recurringTasks = attributes.recurringTasks.map((task) => new RecurringTask(task));
|
|
9
|
+
}
|
|
10
|
+
const instance = new (constGet(TopLevel, processClass))(attributes);
|
|
11
|
+
instance.supervisedBy(await Process.find(supervisorId));
|
|
12
|
+
instance.name = name;
|
|
13
|
+
instance.mode = "fork";
|
|
14
|
+
const bootGuard = new ForkGuard();
|
|
15
|
+
[
|
|
16
|
+
bootGuard._reader,
|
|
17
|
+
bootGuard._writer,
|
|
18
|
+
] = rbForkedPipe(0);
|
|
19
|
+
instance._bootGuard = bootGuard;
|
|
20
|
+
instance.registerSignalHandlers();
|
|
21
|
+
await instance.boot();
|
|
22
|
+
await instance.run();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AAU,GAAG,SAAS,CAAC;AAEhC,QAAQ,CAAC,sBAAsB,EAAE,CAAC;AAClC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;AACtB,MAAM,QAAQ,CAAC,GAAG,EAAE,CAAC;AAErB,QAAQ,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Queue } from "@blazetrails/ruby-compat";
|
|
2
|
+
import { type Duration } from "@blazetrails/activesupport";
|
|
3
|
+
interface InterruptibleHost {
|
|
4
|
+
_queue?: Queue<boolean>;
|
|
5
|
+
queue(): Queue<boolean>;
|
|
6
|
+
interrupt(): Promise<void>;
|
|
7
|
+
handleThreadError(error: unknown): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const Interruptible: {
|
|
10
|
+
wakeUp(this: InterruptibleHost): Promise<void>;
|
|
11
|
+
/** @internal */
|
|
12
|
+
interrupt(this: InterruptibleHost): Promise<void>;
|
|
13
|
+
/** @internal */
|
|
14
|
+
interruptibleSleep(this: InterruptibleHost, time: number | Duration): Promise<null>;
|
|
15
|
+
/** @internal */
|
|
16
|
+
queue(this: InterruptibleHost): Queue<boolean>;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=interruptible.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Queue, RuntimeError } from "@blazetrails/ruby-compat";
|
|
2
|
+
import { include } from "@blazetrails/activesupport";
|
|
3
|
+
import { AppExecutor } from "../app-executor.js";
|
|
4
|
+
export const Interruptible = {
|
|
5
|
+
async wakeUp() {
|
|
6
|
+
await this.interrupt();
|
|
7
|
+
},
|
|
8
|
+
/** @internal */
|
|
9
|
+
async interrupt() {
|
|
10
|
+
await this.queue().push(true);
|
|
11
|
+
},
|
|
12
|
+
/** @internal */
|
|
13
|
+
async interruptibleSleep(time) {
|
|
14
|
+
try {
|
|
15
|
+
const timeout = Number(time);
|
|
16
|
+
if ((await this.queue().pop(false, { timeout })) != null)
|
|
17
|
+
this.queue().clear();
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
const wrappedException = new RuntimeError(`Interruptible#interruptible_sleep - ${e.constructor.name}: ${e.message}`);
|
|
21
|
+
wrappedException.stack = e.stack;
|
|
22
|
+
this.handleThreadError(wrappedException);
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
},
|
|
26
|
+
/** @internal */
|
|
27
|
+
queue() {
|
|
28
|
+
return (this._queue ??= new Queue());
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
include(Interruptible, AppExecutor);
|
|
32
|
+
//# sourceMappingURL=interruptible.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interruptible.js","sourceRoot":"","sources":["../../lib/processes/interruptible.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAiB,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AASjD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;IACzB,CAAC;IAED,gBAAgB;IAChB,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,gBAAgB;IAChB,KAAK,CAAC,kBAAkB,CAA0B,IAAuB;QACvE,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,IAAI;gBAAE,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC;QACjF,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,gBAAgB,GAAG,IAAI,YAAY,CACvC,uCAAwC,CAAW,CAAC,WAAW,CAAC,IAAI,KAAM,CAAW,CAAC,OAAO,EAAE,CAChG,CAAC;YACF,gBAAgB,CAAC,KAAK,GAAI,CAAW,CAAC,KAAK,CAAC;YAC5C,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IAChB,KAAK;QACH,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,KAAK,EAAW,CAAC,CAAC;IAChD,CAAC;CACF,CAAC;AACF,OAAO,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Thread } from "@blazetrails/ruby-compat";
|
|
2
|
+
import { Base } from "./base.js";
|
|
3
|
+
export declare class Poller extends Base {
|
|
4
|
+
pollingInterval: unknown;
|
|
5
|
+
_thread?: Thread;
|
|
6
|
+
constructor({ pollingInterval, ...options }: {
|
|
7
|
+
pollingInterval: unknown;
|
|
8
|
+
} & object);
|
|
9
|
+
metadata(): Promise<Record<string, unknown>>;
|
|
10
|
+
/** @inlinedFrom SolidQueue::Processes::Runnable#stop solid_queue/v1.7.2/lib/solid_queue/processes/runnable.rb:18-28 */
|
|
11
|
+
stop(): Promise<void>;
|
|
12
|
+
/** @internal */
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
/** @internal */
|
|
15
|
+
startLoop(): Promise<void>;
|
|
16
|
+
/** @internal */
|
|
17
|
+
poll(): Promise<unknown>;
|
|
18
|
+
/** @internal */
|
|
19
|
+
withPollingVolume<T>(block: () => Promise<T>): Promise<T>;
|
|
20
|
+
}
|
|
21
|
+
export interface Poller {
|
|
22
|
+
mode: unknown;
|
|
23
|
+
isSupervised(): boolean;
|
|
24
|
+
start(): Promise<void>;
|
|
25
|
+
isShuttingDown(): Promise<boolean>;
|
|
26
|
+
shutdown(): Promise<void>;
|
|
27
|
+
setProcline(): void | Promise<void>;
|
|
28
|
+
isAllWorkCompleted(): Promise<boolean>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=poller.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ActiveRecord } from "@blazetrails/activerecord";
|
|
2
|
+
import { include } from "@blazetrails/activesupport";
|
|
3
|
+
import { NotImplementedError } from "@blazetrails/ruby-compat";
|
|
4
|
+
import { SolidQueue } from "../solid-queue.js";
|
|
5
|
+
import { Base } from "./base.js";
|
|
6
|
+
import { Runnable } from "./runnable.js";
|
|
7
|
+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- see the interface below. */
|
|
8
|
+
export class Poller extends Base {
|
|
9
|
+
static {
|
|
10
|
+
include(this, Runnable);
|
|
11
|
+
}
|
|
12
|
+
pollingInterval;
|
|
13
|
+
constructor({ pollingInterval, ...options }) {
|
|
14
|
+
super(options);
|
|
15
|
+
this.pollingInterval = pollingInterval;
|
|
16
|
+
}
|
|
17
|
+
async metadata() {
|
|
18
|
+
return { ...(await super.metadata()), polling_interval: this.pollingInterval };
|
|
19
|
+
}
|
|
20
|
+
/** @inlinedFrom SolidQueue::Processes::Runnable#stop solid_queue/v1.7.2/lib/solid_queue/processes/runnable.rb:18-28 */
|
|
21
|
+
async stop() {
|
|
22
|
+
await super.stop();
|
|
23
|
+
await this.wakeUp();
|
|
24
|
+
if (!this.isSupervised()) {
|
|
25
|
+
await this._thread?.join();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** @internal */
|
|
29
|
+
async run() {
|
|
30
|
+
await this.startLoop();
|
|
31
|
+
}
|
|
32
|
+
/** @internal */
|
|
33
|
+
async startLoop() {
|
|
34
|
+
try {
|
|
35
|
+
while (true) {
|
|
36
|
+
if (await this.isShuttingDown())
|
|
37
|
+
break;
|
|
38
|
+
const delay = await this.wrapInAppExecutor(() => this.poll());
|
|
39
|
+
await this.interruptibleSleep(delay);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
await SolidQueue.instrument("shutdown_process", { process: this }, async () => {
|
|
44
|
+
await this.runCallbacks("shutdown", () => this.shutdown());
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** @internal */
|
|
49
|
+
async poll() {
|
|
50
|
+
throw new NotImplementedError();
|
|
51
|
+
}
|
|
52
|
+
/** @internal */
|
|
53
|
+
async withPollingVolume(block) {
|
|
54
|
+
return await SolidQueue.instrument("polling", {}, async () => {
|
|
55
|
+
if (SolidQueue.isSilencePolling() && ActiveRecord.Base.logger) {
|
|
56
|
+
return (await ActiveRecord.Base.logger.silence(undefined, () => block()));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return await block();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=poller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../lib/processes/poller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAe,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,2GAA2G;AAC3G,MAAM,OAAO,MAAO,SAAQ,IAAI;IAC9B;QACE,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC1B,CAAC;IAED,eAAe,CAAU;IAGzB,YAAY,EAAE,eAAe,EAAE,GAAG,OAAO,EAAyC;QAChF,KAAK,CAAC,O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