@delali/narsil 0.3.1-next.112 → 0.3.1-next.115
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/browser/{chunk-UR5MNN53.mjs → chunk-2TMWIATH.mjs} +108 -67
- package/dist/browser/{chunk-OVY4RPDS.mjs → chunk-73U5DWOZ.mjs} +39 -4
- package/dist/browser/{chunk-O5IKTA27.mjs → chunk-FODCC3MK.mjs} +1 -1
- package/dist/browser/{chunk-YRYBTRWB.mjs → chunk-I45FAGOF.mjs} +2 -2
- package/dist/browser/{durability-wiring-CPEMDDK7.mjs → durability-wiring-CSMTKEYX.mjs} +3 -3
- package/dist/browser/{module-DYKR4INA.mjs → module-G2PPZV3B.mjs} +127 -33
- package/dist/browser/{restore-queue-2H4QDQV4.mjs → restore-queue-N7N42PBS.mjs} +1 -1
- package/dist/browser/{runtime-FL5K4JOH.mjs → runtime-BX6XRFYR.mjs} +2 -2
- package/dist/browser/{snapshot-ISZMBDCN.mjs → snapshot-EBH6RXQO.mjs} +6 -5
- package/dist/browser/{write-IABOLE4N.mjs → write-5ZKFINX3.mjs} +2 -2
- package/dist/{capabilities-ByaX8Arf.d.ts → capabilities-DOgB3pPf.d.ts} +2 -2
- package/dist/{chunk-ZXZ26WSO.mjs → chunk-22YPZVMG.mjs} +5 -1
- package/dist/{chunk-R2MRGYU5.mjs → chunk-4ZKBKPBV.mjs} +22 -2
- package/dist/{chunk-GLZI636G.mjs → chunk-5VVSHCXT.mjs} +27 -12
- package/dist/{chunk-3COL24MT.mjs → chunk-7EWQZQDT.mjs} +1 -1
- package/dist/{chunk-QI6JW4PM.mjs → chunk-BCNUJVTT.mjs} +1 -1
- package/dist/{chunk-3RRATITJ.mjs → chunk-BCSWODXP.mjs} +75 -55
- package/dist/{thread-WGBCVJII.mjs → chunk-DEXID4ZT.mjs} +301 -200
- package/dist/chunk-EBIHRL7B.mjs +21 -0
- package/dist/{chunk-YIDSHBQS.mjs → chunk-HC5NURS6.mjs} +33 -4
- package/dist/{chunk-V7G627TA.mjs → chunk-HFJXEFFV.mjs} +13 -62
- package/dist/{chunk-63HFWQEA.mjs → chunk-IE43SRL3.mjs} +276 -102
- package/dist/chunk-IWVEG5CX.mjs +67 -0
- package/dist/{chunk-2IFU7SXG.mjs → chunk-KGVC6KJ3.mjs} +4 -4
- package/dist/{chunk-7CI34JAP.mjs → chunk-KVLX65KD.mjs} +4 -4
- package/dist/{chunk-5WEBVYOA.mjs → chunk-N53HN5VA.mjs} +16 -9
- package/dist/chunk-N6J6EJW3.mjs +198 -0
- package/dist/{chunk-PT7VRWS7.mjs → chunk-NX7KU77V.mjs} +3 -2
- package/dist/{chunk-QIFOXLWF.mjs → chunk-OGFSUXYY.mjs} +2 -2
- package/dist/chunk-PELHVTO7.mjs +24 -0
- package/dist/{chunk-V7ISFBFC.mjs → chunk-Q62NDKEC.mjs} +5 -4
- package/dist/{chunk-6OXNHLNZ.mjs → chunk-RIIUZJQ3.mjs} +1 -1
- package/dist/{chunk-BVOUSX3U.mjs → chunk-UDZYIWDP.mjs} +3 -3
- package/dist/{chunk-HNAP2KTG.mjs → chunk-VFAXPDBH.mjs} +1 -0
- package/dist/{chunk-IBTKJIV7.mjs → chunk-VOKEYJHU.mjs} +1 -1
- package/dist/{chunk-C7SLA6CM.mjs → chunk-W55X2BYN.mjs} +5 -1
- package/dist/{chunk-IM76DLA7.mjs → chunk-YCFQ5754.mjs} +2 -2
- package/dist/{chunk-VLRT47GU.mjs → chunk-YCSRB3IN.mjs} +3 -3
- package/dist/{chunk-CQUMNIIG.mjs → chunk-Z4DZ4KK2.mjs} +1 -0
- package/dist/{chunk-SOADQINJ.mjs → chunk-ZATRDAYU.mjs} +31 -3
- package/dist/{chunk-2RAQKITH.mjs → chunk-ZR63OGT2.mjs} +1 -1
- package/dist/{client-BdnzDFtO.d.ts → client-BGzLNt78.d.ts} +2 -2
- package/dist/client.d.ts +6 -6
- package/dist/{config-ujZESkJz.d.ts → config-CS5ADSrx.d.ts} +18 -2
- package/dist/{config-CSgvApt0.d.ts → config-CSYMTTm1.d.ts} +1 -1
- package/dist/{direct-executor-ZSTKRA6Z.mjs → direct-executor-OUY4RPTU.mjs} +7 -6
- package/dist/distribution.d.ts +5 -5
- package/dist/distribution.mjs +79 -42
- package/dist/{durability-wiring-EQTFL3B4.mjs → durability-wiring-5V6DVHFK.mjs} +17 -16
- package/dist/{engine-C_HSy3iz.d.ts → engine-CCBBGmMR.d.ts} +1 -1
- package/dist/{events-CJsXF1F9.d.ts → events-D8GPB1-H.d.ts} +5 -0
- package/dist/index.browser.mjs +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +10 -9
- package/dist/long-query-thread-HMQM2FWL.mjs +118 -0
- package/dist/{module-WP4VVGV2.mjs → module-3IMTXNPW.mjs} +92 -29
- package/dist/pattern.mjs +1 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +14 -13
- package/dist/react.d.ts +6 -6
- package/dist/{rerank-3POMPQNX.mjs → rerank-NYX5S7OG.mjs} +3 -3
- package/dist/{restore-queue-WZTMTJP2.mjs → restore-queue-J6PCG4ON.mjs} +1 -1
- package/dist/{runtime-C2435MPK.mjs → runtime-XNYW6AWX.mjs} +2 -2
- package/dist/server.d.ts +8 -8
- package/dist/server.mjs +110 -258
- package/dist/{snapshot-EU6NNB2P.mjs → snapshot-57WF53MK.mjs} +18 -17
- package/dist/{tasks-CI3Fvkxw.d.ts → tasks-5_LCFEzF.d.ts} +1 -1
- package/dist/thread-FDEHU5G3.mjs +31 -0
- package/dist/vector/search-worker.mjs +2 -2
- package/dist/workers/entry.mjs +19 -7
- package/dist/{write-CKRWS3P5.mjs → write-YEI7A5OR.mjs} +11 -10
- package/package.json +7 -7
package/dist/server.mjs
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { answerRequest } from './chunk-N6J6EJW3.mjs';
|
|
2
|
+
import { DEFAULT_MAX_RETAINED_TASKS, loadUWebSockets, resolveCors, authorizerFor, createSharedGateBuffer, gateSlotOfWorker, createBodyBudgetBuffer, createRouteRunner, corsHeaderReader, createSharedBodyBudget, MAIN_THREAD_GATE_SLOT, createSharedRequestGate, registerServerRoutes, DEFAULT_MAX_CONCURRENT_TASKS, DEFAULT_MAX_TASK_PAGE_SIZE, DEFAULT_MAX_IMPORT_ERRORS, DEFAULT_MAX_FETCH_DOCUMENTS, DEFAULT_MAX_RESULT_WINDOW, DEFAULT_MAX_CONCURRENT_REQUESTS, DEFAULT_IMPORT_BATCH_SIZE, DEFAULT_MAX_LINE_BYTES, DEFAULT_MAX_RESTORE_BYTES, DEFAULT_MAX_IMPORT_BYTES, DEFAULT_MAX_BODY_BYTES, DEFAULT_MAX_RERANK_WINDOW, DEFAULT_MAX_BODY_BYTES_IN_FLIGHT_FRACTION, RUNNING_TASK_TTL_MS, DEFAULT_TASK_PAGE_SIZE, TERMINAL_TASK_TTL_MS, TASK_PROGRESS_WRITE_INTERVAL_MS, serializeNarsilError, createVersionHandler, acceptorOf, MAX_BODY_BYTES_IN_FLIGHT_FRACTION, createDocumentReadHandlers, sendError, respondError, respondJson, sendText, MAX_INDEX_TOUCH_INTERVAL_MS, INDEX_TOUCH_INTERVALS_PER_IDLE_TIMEOUT, closeEveryThreadAtExit, REQUEST_THREAD_CLOSE_AT_EXIT_MS, clearGateSlot, clearBodyBudgetSlot, createCloseAtExitWords, createDepartureWord, departureConfirmed, parseJson, validateCreateIndex, rejectInvalid, isRemoveOnlyBatch, validateBatch, serializeBatchResult, parseWriteJson, validateDocumentBody, validateSuggest, validateQuery, refuseRegex, withServerRerankWindow, respondAnswer, parseTaskListQuery, parseJsonOptional, validateRebalance, badRequest, sendStream, SNAPSHOT_ARCHIVE_CONTENT_TYPE, DOCUMENT_EXPORT_CONTENT_TYPE, parseRefusalOf, IMPORT_FLUSHES_IN_FLIGHT, confirmDeparture, SERVER_CAPABILITIES, toHttpError, MIN_UNBOUNDED_SERVER_LIMIT, MIN_COUNTED_SERVER_LIMIT } from './chunk-IE43SRL3.mjs';
|
|
3
|
+
export { ASYNC_IMPORT_CAPABILITY, DOCUMENT_EXPORT_CAPABILITY, INDEX_LIFECYCLE_CAPABILITY, REBUILD_ANALYSIS_CAPABILITY, SERVER_CAPABILITIES, SYNONYMS_CAPABILITY, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY, httpStatusForNarsilError } from './chunk-IE43SRL3.mjs';
|
|
3
4
|
import { rerankOnHost } from './chunk-542TD4BL.mjs';
|
|
4
5
|
import { writeBlockLookupOf, indexReadsOf, isRecord, validateIndexName } from './chunk-LOBYK2FG.mjs';
|
|
5
|
-
import { readMemoryFigures } from './chunk-
|
|
6
|
+
import { readMemoryFigures } from './chunk-HFJXEFFV.mjs';
|
|
7
|
+
import './chunk-IWVEG5CX.mjs';
|
|
6
8
|
import './chunk-DJHHF2L5.mjs';
|
|
7
9
|
import './chunk-P36MUFEJ.mjs';
|
|
8
10
|
import { rerankWindowCapOf, engineCoreOf, providedDocId, resolveVectorText } from './chunk-N57XXGPG.mjs';
|
|
9
11
|
import { detectRuntime } from './chunk-AV4IJKD2.mjs';
|
|
10
12
|
import './chunk-FUUP45IS.mjs';
|
|
11
|
-
import './chunk-
|
|
13
|
+
import './chunk-ZATRDAYU.mjs';
|
|
14
|
+
import './chunk-EBIHRL7B.mjs';
|
|
12
15
|
import { MAX_RERANK_WINDOW } from './chunk-HJSN7UYG.mjs';
|
|
13
16
|
import './chunk-LXWDQLTW.mjs';
|
|
14
17
|
import './chunk-TGP5M5R7.mjs';
|
|
@@ -23,15 +26,13 @@ import './chunk-6ODIY6ZB.mjs';
|
|
|
23
26
|
import './chunk-7X5JST5L.mjs';
|
|
24
27
|
import './chunk-R6A773WK.mjs';
|
|
25
28
|
import './chunk-YTJCGKM4.mjs';
|
|
26
|
-
import { startIdleHeapCleanup } from './chunk-
|
|
27
|
-
import './chunk-
|
|
29
|
+
import { startIdleHeapCleanup } from './chunk-RIIUZJQ3.mjs';
|
|
30
|
+
import './chunk-22YPZVMG.mjs';
|
|
28
31
|
import './chunk-L5ORED7V.mjs';
|
|
29
32
|
import { NarsilError, ErrorCodes, ServerErrorCodes, isNarsilError } from './chunk-OBWUWZRA.mjs';
|
|
30
33
|
export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes, isNarsilError } from './chunk-OBWUWZRA.mjs';
|
|
31
34
|
import { randomUUID } from 'crypto';
|
|
32
35
|
import { createReadStream } from 'fs';
|
|
33
|
-
import { rm } from 'fs/promises';
|
|
34
|
-
import path from 'path';
|
|
35
36
|
import { MessageChannel } from 'worker_threads';
|
|
36
37
|
|
|
37
38
|
function createAdminHandlers(deps) {
|
|
@@ -408,62 +409,6 @@ function createDocumentExportHandlers(deps) {
|
|
|
408
409
|
return { exportDocuments, importExport };
|
|
409
410
|
}
|
|
410
411
|
|
|
411
|
-
// src/server/batch-scan.ts
|
|
412
|
-
var QUOTE = 34;
|
|
413
|
-
var BACKSLASH = 92;
|
|
414
|
-
var OPEN_OBJECT = 123;
|
|
415
|
-
var CLOSE_OBJECT = 125;
|
|
416
|
-
var OPEN_ARRAY = 91;
|
|
417
|
-
var CLOSE_ARRAY = 93;
|
|
418
|
-
var COLON = 58;
|
|
419
|
-
var REMOVE_BATCH_KEYS = /* @__PURE__ */ new Set(["action", "docIds", "options"]);
|
|
420
|
-
var REMOVE_ACTION = "delete";
|
|
421
|
-
function isWhitespace(byte) {
|
|
422
|
-
return byte === 32 || byte === 9 || byte === 10 || byte === 13;
|
|
423
|
-
}
|
|
424
|
-
function nextByteAt(raw, from) {
|
|
425
|
-
let at = from;
|
|
426
|
-
while (at < raw.length && isWhitespace(raw[at])) at++;
|
|
427
|
-
return at;
|
|
428
|
-
}
|
|
429
|
-
function plainStringOf(raw, open, close) {
|
|
430
|
-
const content = raw.subarray(open + 1, close);
|
|
431
|
-
if (content.includes(BACKSLASH)) return null;
|
|
432
|
-
return new TextDecoder().decode(content);
|
|
433
|
-
}
|
|
434
|
-
function isRemoveOnlyBatch(raw) {
|
|
435
|
-
const start = nextByteAt(raw, 0);
|
|
436
|
-
if (raw[start] !== OPEN_OBJECT) return false;
|
|
437
|
-
let depth = 0;
|
|
438
|
-
let action = null;
|
|
439
|
-
for (let at = start; at < raw.length; at++) {
|
|
440
|
-
const byte = raw[at];
|
|
441
|
-
if (byte === OPEN_OBJECT || byte === OPEN_ARRAY) depth++;
|
|
442
|
-
else if (byte === CLOSE_OBJECT || byte === CLOSE_ARRAY) depth--;
|
|
443
|
-
else if (byte === QUOTE) {
|
|
444
|
-
const close = closingQuoteOf(raw, at + 1);
|
|
445
|
-
if (close >= raw.length) return false;
|
|
446
|
-
const afterString = nextByteAt(raw, close + 1);
|
|
447
|
-
if (depth === 1 && raw[afterString] === COLON) {
|
|
448
|
-
const key = plainStringOf(raw, at, close);
|
|
449
|
-
if (key === null || !REMOVE_BATCH_KEYS.has(key)) return false;
|
|
450
|
-
if (key === "action") {
|
|
451
|
-
const value = nextByteAt(raw, afterString + 1);
|
|
452
|
-
const valueClose = raw[value] === QUOTE ? closingQuoteOf(raw, value + 1) : raw.length;
|
|
453
|
-
action = valueClose < raw.length ? plainStringOf(raw, value, valueClose) : null;
|
|
454
|
-
if (action === null) return false;
|
|
455
|
-
at = valueClose;
|
|
456
|
-
continue;
|
|
457
|
-
}
|
|
458
|
-
at = afterString;
|
|
459
|
-
continue;
|
|
460
|
-
}
|
|
461
|
-
at = close;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return action === REMOVE_ACTION;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
412
|
// src/server/handlers/documents.ts
|
|
468
413
|
function createDocumentHandlers(deps) {
|
|
469
414
|
const { engine } = deps;
|
|
@@ -971,6 +916,17 @@ function prometheusText(metrics) {
|
|
|
971
916
|
])} ${figure.inSyncReplicas}`
|
|
972
917
|
)
|
|
973
918
|
),
|
|
919
|
+
...family(
|
|
920
|
+
"narsil_vector_rebuild_waiting_for_memory",
|
|
921
|
+
"gauge",
|
|
922
|
+
"A vector field whose rebuild waits for the node to have memory for a second graph, reported as 1.",
|
|
923
|
+
metrics.vectorRebuildsWaitingForMemory.map(
|
|
924
|
+
(figure) => `narsil_vector_rebuild_waiting_for_memory${labels([
|
|
925
|
+
["index", figure.indexName],
|
|
926
|
+
["field", figure.fieldName]
|
|
927
|
+
])} 1`
|
|
928
|
+
)
|
|
929
|
+
),
|
|
974
930
|
...family(
|
|
975
931
|
"narsil_coordinator_request_seconds",
|
|
976
932
|
"histogram",
|
|
@@ -1140,167 +1096,12 @@ function assertAllowRegex(allowRegex) {
|
|
|
1140
1096
|
{ field: "allowRegex", value: String(allowRegex) }
|
|
1141
1097
|
);
|
|
1142
1098
|
}
|
|
1143
|
-
|
|
1144
|
-
// src/server/request-threads/captured-response.ts
|
|
1145
|
-
var DEFAULT_STATUS = 200;
|
|
1146
|
-
var NO_RESPONSE_STATUS = 500;
|
|
1147
|
-
function statusOf(line) {
|
|
1148
|
-
const parsed = Number.parseInt(line, 10);
|
|
1149
|
-
return Number.isFinite(parsed) ? parsed : DEFAULT_STATUS;
|
|
1150
|
-
}
|
|
1151
|
-
function bodyBytes(body) {
|
|
1152
|
-
if (body === void 0) return new Uint8Array(0);
|
|
1153
|
-
if (typeof body === "string") return Buffer.from(body, "utf8");
|
|
1154
|
-
return body;
|
|
1155
|
-
}
|
|
1156
|
-
function createRelayAbort() {
|
|
1157
|
-
const listeners = [];
|
|
1158
|
-
let aborted = false;
|
|
1159
|
-
return {
|
|
1160
|
-
get aborted() {
|
|
1161
|
-
return aborted;
|
|
1162
|
-
},
|
|
1163
|
-
onAbort(fn) {
|
|
1164
|
-
if (aborted) fn();
|
|
1165
|
-
else listeners.push(fn);
|
|
1166
|
-
},
|
|
1167
|
-
trigger() {
|
|
1168
|
-
if (aborted) return;
|
|
1169
|
-
aborted = true;
|
|
1170
|
-
for (const fn of listeners) fn();
|
|
1171
|
-
}
|
|
1172
|
-
};
|
|
1173
|
-
}
|
|
1174
|
-
function createCapturingResponse(remoteAddress, requestId, sendPart) {
|
|
1175
|
-
let status = DEFAULT_STATUS;
|
|
1176
|
-
const headers = [];
|
|
1177
|
-
let finished = false;
|
|
1178
|
-
let streaming = false;
|
|
1179
|
-
let inFlight = 0;
|
|
1180
|
-
let writable = null;
|
|
1181
|
-
const abort = createRelayAbort();
|
|
1182
|
-
let resolveDone = () => void 0;
|
|
1183
|
-
const done = new Promise((resolve) => {
|
|
1184
|
-
resolveDone = resolve;
|
|
1185
|
-
});
|
|
1186
|
-
function finish(body) {
|
|
1187
|
-
if (finished) return;
|
|
1188
|
-
finished = true;
|
|
1189
|
-
if (streaming) {
|
|
1190
|
-
sendPart({ type: "stream-end", requestId, failed: false }, []);
|
|
1191
|
-
resolveDone(null);
|
|
1192
|
-
return;
|
|
1193
|
-
}
|
|
1194
|
-
resolveDone({ status, headers, body });
|
|
1195
|
-
}
|
|
1196
|
-
function startStreaming() {
|
|
1197
|
-
if (streaming) return;
|
|
1198
|
-
streaming = true;
|
|
1199
|
-
sendPart({ type: "stream-start", requestId, status, headers }, []);
|
|
1200
|
-
}
|
|
1201
|
-
const sink = {
|
|
1202
|
-
cork(callback) {
|
|
1203
|
-
callback();
|
|
1204
|
-
return sink;
|
|
1205
|
-
},
|
|
1206
|
-
writeStatus(line) {
|
|
1207
|
-
if (!finished && !streaming) status = statusOf(line);
|
|
1208
|
-
return sink;
|
|
1209
|
-
},
|
|
1210
|
-
writeHeader(key, value) {
|
|
1211
|
-
if (!finished && !streaming) headers.push([key, value]);
|
|
1212
|
-
return sink;
|
|
1213
|
-
},
|
|
1214
|
-
end(body) {
|
|
1215
|
-
finish(bodyBytes(body));
|
|
1216
|
-
return sink;
|
|
1217
|
-
},
|
|
1218
|
-
write(chunk) {
|
|
1219
|
-
if (finished || abort.aborted) return true;
|
|
1220
|
-
startStreaming();
|
|
1221
|
-
const copy = new Uint8Array(chunk.byteLength);
|
|
1222
|
-
copy.set(chunk);
|
|
1223
|
-
inFlight += 1;
|
|
1224
|
-
sendPart({ type: "stream-chunk", requestId, chunk: copy }, [copy.buffer]);
|
|
1225
|
-
return inFlight < RELAY_STREAM_CHUNKS_IN_FLIGHT;
|
|
1226
|
-
},
|
|
1227
|
-
pause: () => void 0,
|
|
1228
|
-
resume: () => void 0,
|
|
1229
|
-
close() {
|
|
1230
|
-
if (finished) return sink;
|
|
1231
|
-
finished = true;
|
|
1232
|
-
if (streaming) {
|
|
1233
|
-
sendPart({ type: "stream-end", requestId, failed: true }, []);
|
|
1234
|
-
resolveDone(null);
|
|
1235
|
-
} else {
|
|
1236
|
-
status = NO_RESPONSE_STATUS;
|
|
1237
|
-
resolveDone({ status, headers, body: new Uint8Array(0) });
|
|
1238
|
-
}
|
|
1239
|
-
return sink;
|
|
1240
|
-
},
|
|
1241
|
-
endWithoutBody() {
|
|
1242
|
-
finish(new Uint8Array(0));
|
|
1243
|
-
return sink;
|
|
1244
|
-
},
|
|
1245
|
-
tryEnd(body) {
|
|
1246
|
-
finish(body);
|
|
1247
|
-
return [true, true];
|
|
1248
|
-
},
|
|
1249
|
-
getWriteOffset: () => 0,
|
|
1250
|
-
onWritable(handler) {
|
|
1251
|
-
writable = handler;
|
|
1252
|
-
return sink;
|
|
1253
|
-
},
|
|
1254
|
-
onAborted: () => sink,
|
|
1255
|
-
onData: () => sink,
|
|
1256
|
-
getRemoteAddressAsText: () => new TextEncoder().encode(remoteAddress).buffer
|
|
1257
|
-
};
|
|
1258
|
-
return {
|
|
1259
|
-
sink,
|
|
1260
|
-
abort,
|
|
1261
|
-
done,
|
|
1262
|
-
credit() {
|
|
1263
|
-
inFlight = Math.max(0, inFlight - 1);
|
|
1264
|
-
if (inFlight >= RELAY_STREAM_CHUNKS_IN_FLIGHT || writable === null) return;
|
|
1265
|
-
const handler = writable;
|
|
1266
|
-
writable = null;
|
|
1267
|
-
handler(0);
|
|
1268
|
-
},
|
|
1269
|
-
cancel() {
|
|
1270
|
-
abort.trigger();
|
|
1271
|
-
if (writable !== null) {
|
|
1272
|
-
const handler = writable;
|
|
1273
|
-
writable = null;
|
|
1274
|
-
handler(0);
|
|
1275
|
-
}
|
|
1276
|
-
if (!finished) {
|
|
1277
|
-
finished = true;
|
|
1278
|
-
resolveDone(null);
|
|
1279
|
-
}
|
|
1280
|
-
},
|
|
1281
|
-
finishUnanswered() {
|
|
1282
|
-
if (finished) return;
|
|
1283
|
-
if (streaming) {
|
|
1284
|
-
finished = true;
|
|
1285
|
-
sendPart({ type: "stream-end", requestId, failed: true }, []);
|
|
1286
|
-
resolveDone(null);
|
|
1287
|
-
return;
|
|
1288
|
-
}
|
|
1289
|
-
status = NO_RESPONSE_STATUS;
|
|
1290
|
-
finish(new Uint8Array(0));
|
|
1291
|
-
}
|
|
1292
|
-
};
|
|
1293
|
-
}
|
|
1294
|
-
function toRelayedResponse(requestId, captured) {
|
|
1295
|
-
return { type: "response", requestId, status: captured.status, headers: captured.headers, body: captured.body };
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
// src/server/request-threads/host.ts
|
|
1299
1099
|
var RELAYED_TYPES = /* @__PURE__ */ new Set([
|
|
1300
1100
|
"request",
|
|
1301
1101
|
"authorize",
|
|
1302
1102
|
"embed",
|
|
1303
1103
|
"rerank",
|
|
1104
|
+
"await-writes",
|
|
1304
1105
|
"stream-credit",
|
|
1305
1106
|
"stream-cancel"
|
|
1306
1107
|
]);
|
|
@@ -1310,41 +1111,6 @@ function isRelayRequest(message) {
|
|
|
1310
1111
|
if (type === "touch" || type === "leaving") return true;
|
|
1311
1112
|
return typeof requestId === "number" && typeof type === "string" && RELAYED_TYPES.has(type);
|
|
1312
1113
|
}
|
|
1313
|
-
function spooledBodyOf(relayed) {
|
|
1314
|
-
if (relayed === null) return null;
|
|
1315
|
-
return {
|
|
1316
|
-
path: relayed.path,
|
|
1317
|
-
bytes: relayed.bytes,
|
|
1318
|
-
remove: () => rm(path.dirname(relayed.path), { recursive: true, force: true })
|
|
1319
|
-
};
|
|
1320
|
-
}
|
|
1321
|
-
async function answerRequest(handlers, request, port, streams) {
|
|
1322
|
-
const captured = createCapturingResponse(
|
|
1323
|
-
request.hookContext?.remoteAddress ?? "",
|
|
1324
|
-
request.requestId,
|
|
1325
|
-
(part, moved) => port.postMessage(part, moved)
|
|
1326
|
-
);
|
|
1327
|
-
streams.set(request.requestId, captured);
|
|
1328
|
-
const ctx = {
|
|
1329
|
-
res: captured.sink,
|
|
1330
|
-
params: request.params,
|
|
1331
|
-
query: new URLSearchParams(request.query),
|
|
1332
|
-
contentType: request.contentType,
|
|
1333
|
-
rawBody: request.rawBody === null ? null : Buffer.from(request.rawBody.buffer, request.rawBody.byteOffset, request.rawBody.byteLength),
|
|
1334
|
-
spooledBody: spooledBodyOf(request.spooledBody),
|
|
1335
|
-
abort: captured.abort,
|
|
1336
|
-
hookContext: request.hookContext
|
|
1337
|
-
};
|
|
1338
|
-
try {
|
|
1339
|
-
await handlers[request.route](ctx);
|
|
1340
|
-
} catch {
|
|
1341
|
-
sendError(ctx.res, 500, ServerErrorCodes.INTERNAL_ERROR, "An unexpected error occurred");
|
|
1342
|
-
}
|
|
1343
|
-
captured.finishUnanswered();
|
|
1344
|
-
const answered = await captured.done;
|
|
1345
|
-
streams.delete(request.requestId);
|
|
1346
|
-
return answered === null ? null : toRelayedResponse(request.requestId, answered);
|
|
1347
|
-
}
|
|
1348
1114
|
async function answerAuthorize(authorize, request) {
|
|
1349
1115
|
if (authorize === void 0) {
|
|
1350
1116
|
return { type: "authorized", requestId: request.requestId, denial: null, hookError: false };
|
|
@@ -1390,6 +1156,10 @@ async function answerRerank(core, request) {
|
|
|
1390
1156
|
return { type: "reranked", requestId: request.requestId, scores: null, error: toHttpError(err).body };
|
|
1391
1157
|
}
|
|
1392
1158
|
}
|
|
1159
|
+
async function answerAwaitWrites(core, request) {
|
|
1160
|
+
await core.orchestrator.awaitWrites(request.indexName).catch(() => void 0);
|
|
1161
|
+
return { type: "writes-applied", requestId: request.requestId };
|
|
1162
|
+
}
|
|
1393
1163
|
function touchIntervalFor(copyIdleTimeoutMs) {
|
|
1394
1164
|
return Math.min(MAX_INDEX_TOUCH_INTERVAL_MS, Math.floor(copyIdleTimeoutMs / INDEX_TOUCH_INTERVALS_PER_IDLE_TIMEOUT));
|
|
1395
1165
|
}
|
|
@@ -1401,6 +1171,8 @@ async function startRequestThreads(options) {
|
|
|
1401
1171
|
const searchHooks = core.pluginRegistry.hasHooks("beforeSearch") || core.pluginRegistry.hasHooks("afterSearch");
|
|
1402
1172
|
const touchIntervalMs = touchIntervalFor(core.orchestrator.copyIdleTimeoutMs());
|
|
1403
1173
|
const threads = /* @__PURE__ */ new Map();
|
|
1174
|
+
const longQueriesInFlight = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT);
|
|
1175
|
+
let longQueryThread = null;
|
|
1404
1176
|
const closeAtExit = /* @__PURE__ */ new Set();
|
|
1405
1177
|
let stopped = false;
|
|
1406
1178
|
function closeThreadsAtExit() {
|
|
@@ -1437,12 +1209,23 @@ async function startRequestThreads(options) {
|
|
|
1437
1209
|
streams.get(message.requestId)?.cancel();
|
|
1438
1210
|
return;
|
|
1439
1211
|
}
|
|
1440
|
-
const reply = message.type === "request" ? answerRequest(handlers, message, port, streams) : message.type === "authorize" ? answerAuthorize(authorize, message) : message.type === "embed" ? answerEmbed(core, message) : answerRerank(core, message);
|
|
1212
|
+
const reply = message.type === "request" ? answerRequest(handlers[message.route], message, port, streams) : message.type === "authorize" ? answerAuthorize(authorize, message) : message.type === "embed" ? answerEmbed(core, message) : message.type === "await-writes" ? answerAwaitWrites(core, message) : answerRerank(core, message);
|
|
1441
1213
|
void reply.then((answer) => {
|
|
1442
1214
|
if (answer !== null) port.postMessage(answer);
|
|
1443
1215
|
});
|
|
1444
1216
|
});
|
|
1445
1217
|
}
|
|
1218
|
+
function connectToLongQueries(thread) {
|
|
1219
|
+
if (longQueryThread === null) return;
|
|
1220
|
+
const channel = new MessageChannel();
|
|
1221
|
+
thread.port.postMessage({ type: "long-query-port", port: channel.port1 }, [channel.port1]);
|
|
1222
|
+
longQueryThread.port.postMessage({ type: "long-query-port", port: channel.port2 }, [channel.port2]);
|
|
1223
|
+
}
|
|
1224
|
+
function dropLongQueryThread() {
|
|
1225
|
+
if (longQueryThread === null) return;
|
|
1226
|
+
longQueryThread.port.close();
|
|
1227
|
+
longQueryThread = null;
|
|
1228
|
+
}
|
|
1446
1229
|
async function stopThread(workerId, thread) {
|
|
1447
1230
|
releaseDescriptor(thread);
|
|
1448
1231
|
thread.port.close();
|
|
@@ -1451,6 +1234,46 @@ async function startRequestThreads(options) {
|
|
|
1451
1234
|
await thread.executor.execute({ type: "stopServing", requestId: `stop-serving-${workerId}` }).catch(() => void 0);
|
|
1452
1235
|
}
|
|
1453
1236
|
const listener = {
|
|
1237
|
+
async onLongQueryWorkerReady(workerId, executor) {
|
|
1238
|
+
if (stopped) return;
|
|
1239
|
+
dropLongQueryThread();
|
|
1240
|
+
const channel = new MessageChannel();
|
|
1241
|
+
const relaying = {
|
|
1242
|
+
descriptor: null,
|
|
1243
|
+
port: channel.port2,
|
|
1244
|
+
executor,
|
|
1245
|
+
departure: createDepartureWord(),
|
|
1246
|
+
closeAtExit: createCloseAtExitWords()
|
|
1247
|
+
};
|
|
1248
|
+
relayFrom(relaying);
|
|
1249
|
+
try {
|
|
1250
|
+
await executor.execute(
|
|
1251
|
+
{
|
|
1252
|
+
type: "serveLongQueries",
|
|
1253
|
+
requestId: `serve-long-queries-${workerId}`,
|
|
1254
|
+
settings: {
|
|
1255
|
+
port: channel.port1,
|
|
1256
|
+
touchIntervalMs,
|
|
1257
|
+
limits: options.limits,
|
|
1258
|
+
patternWorkCap: options.core.patternWorkCap,
|
|
1259
|
+
maxRerankWindow: options.core.rerankSettings.maxWindow,
|
|
1260
|
+
allowRegex: options.allowRegex
|
|
1261
|
+
}
|
|
1262
|
+
},
|
|
1263
|
+
[channel.port1]
|
|
1264
|
+
);
|
|
1265
|
+
} catch (err) {
|
|
1266
|
+
channel.port2.close();
|
|
1267
|
+
console.warn(`Worker ${workerId} could not start answering long queries:`, err);
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
if (stopped) {
|
|
1271
|
+
channel.port2.close();
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
longQueryThread = { workerId, port: channel.port2, executor };
|
|
1275
|
+
for (const thread of threads.values()) connectToLongQueries(thread);
|
|
1276
|
+
},
|
|
1454
1277
|
async onWorkerReady(workerId, executor) {
|
|
1455
1278
|
if (stopped) return;
|
|
1456
1279
|
const channel = new MessageChannel();
|
|
@@ -1463,6 +1286,9 @@ async function startRequestThreads(options) {
|
|
|
1463
1286
|
};
|
|
1464
1287
|
relayFrom(thread);
|
|
1465
1288
|
closeAtExit.add(thread.closeAtExit);
|
|
1289
|
+
const longQueries = longQueryThread;
|
|
1290
|
+
const longQueryChannel = longQueries === null ? null : new MessageChannel();
|
|
1291
|
+
const transfer = longQueryChannel === null ? [channel.port1] : [channel.port1, longQueryChannel.port1];
|
|
1466
1292
|
let result;
|
|
1467
1293
|
try {
|
|
1468
1294
|
result = await executor.execute(
|
|
@@ -1485,26 +1311,42 @@ async function startRequestThreads(options) {
|
|
|
1485
1311
|
searchHooks,
|
|
1486
1312
|
patternWorkCap: options.core.patternWorkCap,
|
|
1487
1313
|
maxRerankWindow: options.core.rerankSettings.maxWindow,
|
|
1488
|
-
allowRegex: options.allowRegex
|
|
1314
|
+
allowRegex: options.allowRegex,
|
|
1315
|
+
longQueriesInFlight,
|
|
1316
|
+
longQueryPort: longQueryChannel?.port1 ?? null
|
|
1489
1317
|
}
|
|
1490
1318
|
},
|
|
1491
|
-
|
|
1319
|
+
transfer
|
|
1492
1320
|
);
|
|
1493
1321
|
} catch (err) {
|
|
1494
1322
|
closeAtExit.delete(thread.closeAtExit);
|
|
1495
1323
|
channel.port2.close();
|
|
1324
|
+
longQueryChannel?.port2.close();
|
|
1496
1325
|
console.warn(`Worker ${workerId} could not start taking requests:`, err);
|
|
1497
1326
|
return;
|
|
1498
1327
|
}
|
|
1499
1328
|
thread.descriptor = result.descriptor;
|
|
1500
1329
|
if (stopped || departureConfirmed(thread.departure)) {
|
|
1330
|
+
longQueryChannel?.port2.close();
|
|
1501
1331
|
await stopThread(workerId, thread);
|
|
1502
1332
|
return;
|
|
1503
1333
|
}
|
|
1334
|
+
if (longQueryChannel !== null && longQueries !== null && longQueryThread === longQueries) {
|
|
1335
|
+
longQueries.port.postMessage({ type: "long-query-port", port: longQueryChannel.port2 }, [
|
|
1336
|
+
longQueryChannel.port2
|
|
1337
|
+
]);
|
|
1338
|
+
} else {
|
|
1339
|
+
longQueryChannel?.port2.close();
|
|
1340
|
+
connectToLongQueries(thread);
|
|
1341
|
+
}
|
|
1504
1342
|
acceptor.addChildAppDescriptor(result.descriptor);
|
|
1505
1343
|
threads.set(workerId, thread);
|
|
1506
1344
|
},
|
|
1507
1345
|
onWorkerGone(workerId) {
|
|
1346
|
+
if (longQueryThread?.workerId === workerId) {
|
|
1347
|
+
dropLongQueryThread();
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1508
1350
|
const thread = threads.get(workerId);
|
|
1509
1351
|
if (thread === void 0) return;
|
|
1510
1352
|
threads.delete(workerId);
|
|
@@ -1528,6 +1370,16 @@ async function startRequestThreads(options) {
|
|
|
1528
1370
|
threads.delete(workerId);
|
|
1529
1371
|
return stopThread(workerId, thread);
|
|
1530
1372
|
});
|
|
1373
|
+
const longQueries = longQueryThread;
|
|
1374
|
+
dropLongQueryThread();
|
|
1375
|
+
if (longQueries !== null) {
|
|
1376
|
+
stopping.push(
|
|
1377
|
+
longQueries.executor.execute({ type: "stopServing", requestId: `stop-long-queries-${longQueries.workerId}` }).then(
|
|
1378
|
+
() => void 0,
|
|
1379
|
+
() => void 0
|
|
1380
|
+
)
|
|
1381
|
+
);
|
|
1382
|
+
}
|
|
1531
1383
|
await Promise.all(stopping);
|
|
1532
1384
|
}
|
|
1533
1385
|
};
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { documentsOfPayloadV2 } from './chunk-
|
|
2
|
-
import { buildArchiveFromMemory, archiveStream, memoryCheckpointStore, readSnapshotArchive } from './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import { indexMetadataOf, unpackIndexSnapshotEnvelope, loadSegmentedCheckpoint, writeMetadataEnvelope, readVectorFile, readGraphParts, deserializePayloadV1, SINGLE_NODE_PRIMARY_TERM } from './chunk-
|
|
1
|
+
import { documentsOfPayloadV2 } from './chunk-VOKEYJHU.mjs';
|
|
2
|
+
import { buildArchiveFromMemory, archiveStream, memoryCheckpointStore, readSnapshotArchive } from './chunk-KVLX65KD.mjs';
|
|
3
|
+
import './chunk-NX7KU77V.mjs';
|
|
4
|
+
import { indexMetadataOf, unpackIndexSnapshotEnvelope, loadSegmentedCheckpoint, writeMetadataEnvelope, readVectorFile, readGraphParts, deserializePayloadV1, SINGLE_NODE_PRIMARY_TERM } from './chunk-YCSRB3IN.mjs';
|
|
5
5
|
import { decodeVectorIndexParts, bytesToVectors } from './chunk-OCB7TMUQ.mjs';
|
|
6
|
-
import './chunk-
|
|
6
|
+
import './chunk-HC5NURS6.mjs';
|
|
7
7
|
import './chunk-DJHHF2L5.mjs';
|
|
8
8
|
import './chunk-37CD3OKS.mjs';
|
|
9
|
-
import { manifestKey, encodeSegmentManifest, manifestFileRefs, readSegmentFile } from './chunk-
|
|
10
|
-
import './chunk-
|
|
9
|
+
import { manifestKey, encodeSegmentManifest, manifestFileRefs, readSegmentFile } from './chunk-KGVC6KJ3.mjs';
|
|
10
|
+
import './chunk-7EWQZQDT.mjs';
|
|
11
11
|
import './chunk-P36MUFEJ.mjs';
|
|
12
12
|
import './chunk-YH5OIL7B.mjs';
|
|
13
|
-
import { encodeIndexConfiguration, createByteReader, hasNrslMagic, HEADER_SIZE, readHeader, validateRequiredFieldsInSchema, validateEmbeddingConfig, decodeIndexConfiguration, prepareStoredSynonyms, insertDocumentVectors } from './chunk-
|
|
14
|
-
import { validatePatternValueLimit, requireSurfaceFormsForPartialFields } from './chunk-
|
|
13
|
+
import { encodeIndexConfiguration, createByteReader, hasNrslMagic, HEADER_SIZE, readHeader, validateRequiredFieldsInSchema, validateEmbeddingConfig, decodeIndexConfiguration, prepareStoredSynonyms, insertDocumentVectors } from './chunk-BCSWODXP.mjs';
|
|
14
|
+
import { validatePatternValueLimit, requireSurfaceFormsForPartialFields } from './chunk-5VVSHCXT.mjs';
|
|
15
15
|
import { restoredConfigFields, restoredEmbedding, rejectSnapshot } from './chunk-N57XXGPG.mjs';
|
|
16
16
|
import './chunk-6PN3U6XW.mjs';
|
|
17
17
|
import './chunk-AV4IJKD2.mjs';
|
|
18
|
-
import { decodeEveryStoredDocument } from './chunk-
|
|
19
|
-
import './chunk-
|
|
18
|
+
import { decodeEveryStoredDocument } from './chunk-Q62NDKEC.mjs';
|
|
19
|
+
import './chunk-N53HN5VA.mjs';
|
|
20
20
|
import { getLanguage } from './chunk-FUUP45IS.mjs';
|
|
21
|
-
import { readHeapStatistics, readResidentMemory } from './chunk-
|
|
21
|
+
import { readHeapStatistics, readResidentMemory } from './chunk-ZATRDAYU.mjs';
|
|
22
|
+
import './chunk-EBIHRL7B.mjs';
|
|
22
23
|
import './chunk-HJSN7UYG.mjs';
|
|
23
24
|
import './chunk-LXWDQLTW.mjs';
|
|
24
25
|
import './chunk-TGP5M5R7.mjs';
|
|
@@ -26,7 +27,7 @@ import './chunk-U2BKYEC7.mjs';
|
|
|
26
27
|
import './chunk-KOKM4PQN.mjs';
|
|
27
28
|
import './chunk-QSK35UC2.mjs';
|
|
28
29
|
import './chunk-VK45J47R.mjs';
|
|
29
|
-
import './chunk-
|
|
30
|
+
import './chunk-VFAXPDBH.mjs';
|
|
30
31
|
import './chunk-WQBCBKY3.mjs';
|
|
31
32
|
import { parseVectorDimension } from './chunk-KCQG2PJT.mjs';
|
|
32
33
|
import { raiseEarlierReleaseGraphSetting, validateSchema, validateVectorPromotion, validateVectorStorage, extractVectorFieldsFromSchema, flattenSchema } from './chunk-DG62H7OD.mjs';
|
|
@@ -41,10 +42,10 @@ import './chunk-7X5JST5L.mjs';
|
|
|
41
42
|
import './chunk-OFYKBKKV.mjs';
|
|
42
43
|
import './chunk-R6A773WK.mjs';
|
|
43
44
|
import './chunk-YTJCGKM4.mjs';
|
|
44
|
-
import { collectAndReturnPages } from './chunk-
|
|
45
|
-
import './chunk-
|
|
46
|
-
import { loadVectorCodeFor } from './chunk-
|
|
47
|
-
import './chunk-
|
|
45
|
+
import { collectAndReturnPages } from './chunk-RIIUZJQ3.mjs';
|
|
46
|
+
import './chunk-Z4DZ4KK2.mjs';
|
|
47
|
+
import { loadVectorCodeFor } from './chunk-BCNUJVTT.mjs';
|
|
48
|
+
import './chunk-22YPZVMG.mjs';
|
|
48
49
|
import './chunk-RFBLQLLZ.mjs';
|
|
49
50
|
import './chunk-L5ORED7V.mjs';
|
|
50
51
|
import { NarsilError, ErrorCodes } from './chunk-OBWUWZRA.mjs';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { closeRequestThread, searchHandler, serveRequests } from './chunk-DEXID4ZT.mjs';
|
|
2
|
+
import './chunk-IE43SRL3.mjs';
|
|
3
|
+
import './chunk-KZ3NX2P7.mjs';
|
|
4
|
+
import './chunk-HFJXEFFV.mjs';
|
|
5
|
+
import './chunk-IWVEG5CX.mjs';
|
|
6
|
+
import './chunk-DJHHF2L5.mjs';
|
|
7
|
+
import './chunk-5VVSHCXT.mjs';
|
|
8
|
+
import './chunk-N53HN5VA.mjs';
|
|
9
|
+
import './chunk-ZATRDAYU.mjs';
|
|
10
|
+
import './chunk-EBIHRL7B.mjs';
|
|
11
|
+
import './chunk-HJSN7UYG.mjs';
|
|
12
|
+
import './chunk-LXWDQLTW.mjs';
|
|
13
|
+
import './chunk-QSK35UC2.mjs';
|
|
14
|
+
import './chunk-VK45J47R.mjs';
|
|
15
|
+
import './chunk-VFAXPDBH.mjs';
|
|
16
|
+
import './chunk-WQBCBKY3.mjs';
|
|
17
|
+
import './chunk-KCQG2PJT.mjs';
|
|
18
|
+
import './chunk-DG62H7OD.mjs';
|
|
19
|
+
import './chunk-U476IXKQ.mjs';
|
|
20
|
+
import './chunk-E74YLAIG.mjs';
|
|
21
|
+
import './chunk-VJS4JFBQ.mjs';
|
|
22
|
+
import './chunk-GES7U2PM.mjs';
|
|
23
|
+
import './chunk-6ODIY6ZB.mjs';
|
|
24
|
+
import './chunk-X5CV2E2B.mjs';
|
|
25
|
+
import './chunk-OFYKBKKV.mjs';
|
|
26
|
+
import './chunk-R6A773WK.mjs';
|
|
27
|
+
import './chunk-YTJCGKM4.mjs';
|
|
28
|
+
import './chunk-RIIUZJQ3.mjs';
|
|
29
|
+
import './chunk-22YPZVMG.mjs';
|
|
30
|
+
import './chunk-L5ORED7V.mjs';
|
|
31
|
+
import './chunk-OBWUWZRA.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { openSharedVectorField, createVectorStore } from '../chunk-
|
|
2
|
-
import { osqBitsOf, createHNSWIndex, createOsqQuantizer } from '../chunk-
|
|
1
|
+
import { openSharedVectorField, createVectorStore } from '../chunk-4ZKBKPBV.mjs';
|
|
2
|
+
import { osqBitsOf, createHNSWIndex, createOsqQuantizer } from '../chunk-HC5NURS6.mjs';
|
|
3
3
|
import '../chunk-DJHHF2L5.mjs';
|
|
4
4
|
import { osqRecordBytes } from '../chunk-37CD3OKS.mjs';
|
|
5
5
|
import '../chunk-KOKM4PQN.mjs';
|
package/dist/workers/entry.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { startIdleHeapCleanup } from '../chunk-
|
|
2
|
-
import { isValidWorkerAction } from '../chunk-
|
|
3
|
-
import { loadVectorCode } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
import { startIdleHeapCleanup } from '../chunk-RIIUZJQ3.mjs';
|
|
2
|
+
import { isValidWorkerAction } from '../chunk-Z4DZ4KK2.mjs';
|
|
3
|
+
import { loadVectorCode } from '../chunk-BCNUJVTT.mjs';
|
|
4
|
+
import '../chunk-22YPZVMG.mjs';
|
|
5
5
|
import { threadSlotOfWorker } from '../chunk-RFBLQLLZ.mjs';
|
|
6
6
|
import '../chunk-L5ORED7V.mjs';
|
|
7
7
|
import { ErrorCodes, NarsilError, isNarsilError } from '../chunk-OBWUWZRA.mjs';
|
|
@@ -22,8 +22,10 @@ async function importBootstrapModule(moduleUrl) {
|
|
|
22
22
|
await import(moduleUrl);
|
|
23
23
|
}
|
|
24
24
|
async function stopServingRequests() {
|
|
25
|
-
const { closeRequestThread } = await import('../thread-
|
|
25
|
+
const { closeRequestThread } = await import('../thread-FDEHU5G3.mjs');
|
|
26
26
|
closeRequestThread();
|
|
27
|
+
const { closeLongQueryThread } = await import('../long-query-thread-HMQM2FWL.mjs');
|
|
28
|
+
closeLongQueryThread();
|
|
27
29
|
}
|
|
28
30
|
function holdsCopies(executor) {
|
|
29
31
|
return typeof executor.queryContextOf === "function";
|
|
@@ -53,7 +55,7 @@ function createActionHandler(executor) {
|
|
|
53
55
|
if (!holdsCopies(executor)) {
|
|
54
56
|
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "This executor holds no copies to answer requests from");
|
|
55
57
|
}
|
|
56
|
-
const starting = import('../thread-
|
|
58
|
+
const starting = import('../thread-FDEHU5G3.mjs').then(
|
|
57
59
|
({ serveRequests }) => serveRequests(executor, action.settings)
|
|
58
60
|
);
|
|
59
61
|
serving.start = starting.then(
|
|
@@ -66,6 +68,16 @@ function createActionHandler(executor) {
|
|
|
66
68
|
post(buildSuccessResponse(action.requestId, result2));
|
|
67
69
|
return false;
|
|
68
70
|
}
|
|
71
|
+
if (action.type === "serveLongQueries") {
|
|
72
|
+
if (!holdsCopies(executor)) {
|
|
73
|
+
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "This executor holds no copies to answer long queries from");
|
|
74
|
+
}
|
|
75
|
+
const { serveLongQueries } = await import('../long-query-thread-HMQM2FWL.mjs');
|
|
76
|
+
serveLongQueries(executor, action.settings);
|
|
77
|
+
servingRequests = true;
|
|
78
|
+
post(buildSuccessResponse(action.requestId, void 0));
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
69
81
|
if (action.type === "stopServing") {
|
|
70
82
|
await stopServingOnceStarted();
|
|
71
83
|
post(buildSuccessResponse(action.requestId, void 0));
|
|
@@ -106,7 +118,7 @@ async function setup() {
|
|
|
106
118
|
} catch {
|
|
107
119
|
parentPort = null;
|
|
108
120
|
}
|
|
109
|
-
const [{ createDirectExecutor }] = await Promise.all([import('../direct-executor-
|
|
121
|
+
const [{ createDirectExecutor }] = await Promise.all([import('../direct-executor-OUY4RPTU.mjs'), loadVectorCode()]);
|
|
110
122
|
const handleAction = createActionHandler(createDirectExecutor({ threadSlot }));
|
|
111
123
|
if (parentPort) {
|
|
112
124
|
const port = parentPort;
|