@ricsam/r5d-worker 0.0.116 → 0.0.118
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/cjs/package.json
CHANGED
|
@@ -59,6 +59,7 @@ class WorkerRecoveryStore {
|
|
|
59
59
|
CREATE TABLE IF NOT EXISTS metadata (key TEXT PRIMARY KEY, value TEXT NOT NULL);
|
|
60
60
|
CREATE TABLE IF NOT EXISTS operations (request_id TEXT PRIMARY KEY, run_id TEXT, session_id TEXT, request_type TEXT NOT NULL, digest TEXT NOT NULL, state TEXT NOT NULL, response TEXT);
|
|
61
61
|
CREATE UNIQUE INDEX IF NOT EXISTS operation_run_start ON operations(run_id) WHERE request_type='exec_start';
|
|
62
|
+
CREATE INDEX IF NOT EXISTS operation_run_state ON operations(run_id,state);
|
|
62
63
|
CREATE TABLE IF NOT EXISTS aliases (request_id TEXT PRIMARY KEY, operation_id TEXT NOT NULL);
|
|
63
64
|
CREATE TABLE IF NOT EXISTS streams (run_id TEXT NOT NULL, stream TEXT NOT NULL, bytes INTEGER NOT NULL DEFAULT 0, acknowledged INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(run_id, stream));
|
|
64
65
|
CREATE TABLE IF NOT EXISTS output (run_id TEXT NOT NULL, stream TEXT NOT NULL, offset INTEGER NOT NULL, bytes INTEGER NOT NULL, data TEXT NOT NULL, PRIMARY KEY(run_id, stream, offset));
|
|
@@ -176,7 +177,8 @@ class WorkerRecoveryStore {
|
|
|
176
177
|
}
|
|
177
178
|
*output(offsets = []) {
|
|
178
179
|
const cursors = new Map(offsets.map((offset) => [offset.runId, offset]));
|
|
179
|
-
|
|
180
|
+
const pendingStreamFilter = offsets.length === 0 ? "bytes>acknowledged AND " : "";
|
|
181
|
+
for (const stream of this.db.query(`SELECT * FROM streams WHERE ${pendingStreamFilter}NOT EXISTS (SELECT 1 FROM operations WHERE operations.run_id=streams.run_id AND operations.state='unknown') ORDER BY rowid`).all()) {
|
|
180
182
|
const supplied = cursors.get(stream.run_id);
|
|
181
183
|
const cursor = supplied ? stream.stream === "stdout" ? supplied.stdoutBytes : supplied.stderrBytes : stream.acknowledged;
|
|
182
184
|
if (cursor >= stream.bytes) continue;
|
package/dist/mjs/package.json
CHANGED
|
@@ -25,6 +25,7 @@ class WorkerRecoveryStore {
|
|
|
25
25
|
CREATE TABLE IF NOT EXISTS metadata (key TEXT PRIMARY KEY, value TEXT NOT NULL);
|
|
26
26
|
CREATE TABLE IF NOT EXISTS operations (request_id TEXT PRIMARY KEY, run_id TEXT, session_id TEXT, request_type TEXT NOT NULL, digest TEXT NOT NULL, state TEXT NOT NULL, response TEXT);
|
|
27
27
|
CREATE UNIQUE INDEX IF NOT EXISTS operation_run_start ON operations(run_id) WHERE request_type='exec_start';
|
|
28
|
+
CREATE INDEX IF NOT EXISTS operation_run_state ON operations(run_id,state);
|
|
28
29
|
CREATE TABLE IF NOT EXISTS aliases (request_id TEXT PRIMARY KEY, operation_id TEXT NOT NULL);
|
|
29
30
|
CREATE TABLE IF NOT EXISTS streams (run_id TEXT NOT NULL, stream TEXT NOT NULL, bytes INTEGER NOT NULL DEFAULT 0, acknowledged INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(run_id, stream));
|
|
30
31
|
CREATE TABLE IF NOT EXISTS output (run_id TEXT NOT NULL, stream TEXT NOT NULL, offset INTEGER NOT NULL, bytes INTEGER NOT NULL, data TEXT NOT NULL, PRIMARY KEY(run_id, stream, offset));
|
|
@@ -142,7 +143,8 @@ class WorkerRecoveryStore {
|
|
|
142
143
|
}
|
|
143
144
|
*output(offsets = []) {
|
|
144
145
|
const cursors = new Map(offsets.map((offset) => [offset.runId, offset]));
|
|
145
|
-
|
|
146
|
+
const pendingStreamFilter = offsets.length === 0 ? "bytes>acknowledged AND " : "";
|
|
147
|
+
for (const stream of this.db.query(`SELECT * FROM streams WHERE ${pendingStreamFilter}NOT EXISTS (SELECT 1 FROM operations WHERE operations.run_id=streams.run_id AND operations.state='unknown') ORDER BY rowid`).all()) {
|
|
146
148
|
const supplied = cursors.get(stream.run_id);
|
|
147
149
|
const cursor = supplied ? stream.stream === "stdout" ? supplied.stdoutBytes : supplied.stderrBytes : stream.acknowledged;
|
|
148
150
|
if (cursor >= stream.bytes) continue;
|