@delali/narsil 0.3.1-next.126 → 0.3.1-next.128
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/{client-DyiYkQ8o.d.ts → client-CsuhZ13c.d.ts} +15 -8
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +34 -18
- package/dist/react.d.ts +1 -1
- package/package.json +7 -7
|
@@ -35,9 +35,15 @@ interface NarsilClientOptions {
|
|
|
35
35
|
*
|
|
36
36
|
* The client moves a request to the next URL when the connection fails, when
|
|
37
37
|
* the request times out, or when the server answers 502, 503, or 504. It
|
|
38
|
-
* tries each URL at most once
|
|
39
|
-
* the last
|
|
40
|
-
*
|
|
38
|
+
* tries each URL at most once as it moves down the list, and it fails with
|
|
39
|
+
* the error from its last try once every URL has failed. `timeoutMs` applies
|
|
40
|
+
* to each try.
|
|
41
|
+
*
|
|
42
|
+
* The client tries a read once more when every URL has failed its connection
|
|
43
|
+
* or answered 502, 503, or 504, so a list of N URLs can take N + 1 requests.
|
|
44
|
+
* With one URL, the second try goes to that same URL. The client sends the
|
|
45
|
+
* extra try straight away, to the first URL in the skip order below. A read
|
|
46
|
+
* that timed out on any URL takes no extra try.
|
|
41
47
|
*
|
|
42
48
|
* The client repeats a request on another URL only where repeating it cannot
|
|
43
49
|
* apply a change twice. A read, meaning a get, a search, a listing, or a
|
|
@@ -82,9 +88,10 @@ interface NarsilClientOptions {
|
|
|
82
88
|
/** The client sends these headers with every request, and a per-call header of the same name replaces one. */
|
|
83
89
|
headers?: Record<string, string>;
|
|
84
90
|
/**
|
|
85
|
-
* The client waits this many milliseconds for an answer before it
|
|
86
|
-
* `CLIENT_REQUEST_TIMEOUT`, and it waits 30000 unless you say
|
|
87
|
-
*
|
|
91
|
+
* The client waits this many milliseconds for an answer on each try before it
|
|
92
|
+
* fails with `CLIENT_REQUEST_TIMEOUT`, and it waits 30000 unless you say
|
|
93
|
+
* otherwise, so a read that tries again can take longer than this in total.
|
|
94
|
+
* Pass 0 so that it waits for as long as the server takes. Three routes carry a
|
|
88
95
|
* corpus or a whole index, so {@link BulkOperations.importDocuments},
|
|
89
96
|
* {@link AdminOperations.snapshot}, and {@link AdminOperations.restore} set no
|
|
90
97
|
* deadline of their own until this one arrives.
|
|
@@ -112,7 +119,7 @@ interface NarsilClientOptions {
|
|
|
112
119
|
interface RequestOptions {
|
|
113
120
|
/** Aborting this stops the request, which then fails with `CLIENT_REQUEST_ABORTED`. */
|
|
114
121
|
signal?: AbortSignal;
|
|
115
|
-
/** The client waits this many milliseconds
|
|
122
|
+
/** The client waits this many milliseconds on each try of this one request, and 0 waits for as long as the server takes. */
|
|
116
123
|
timeoutMs?: number;
|
|
117
124
|
/** The client adds these headers to this request, and one of the same name replaces what it would otherwise send. */
|
|
118
125
|
headers?: Record<string, string>;
|
|
@@ -845,7 +852,7 @@ interface ServerOperations {
|
|
|
845
852
|
/**
|
|
846
853
|
* These settings say how {@link TaskOperations.waitForTask} follows a task.
|
|
847
854
|
*
|
|
848
|
-
* `timeoutMs` bounds each poll request, as it does everywhere else, while
|
|
855
|
+
* `timeoutMs` bounds each try of a poll request, as it does everywhere else, while
|
|
849
856
|
* `waitTimeoutMs` bounds the whole wait.
|
|
850
857
|
*
|
|
851
858
|
* @public
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, N as NarsilError, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes, i as isNarsilError } from './events-x2aVu0_o.js';
|
|
2
2
|
export { A as ASYNC_IMPORT_CAPABILITY, D as DOCUMENT_EXPORT_CAPABILITY, E as ErrorEnvelope, I as INDEX_LIFECYCLE_CAPABILITY, R as REBUILD_ANALYSIS_CAPABILITY, S as SERVER_CAPABILITIES, a as SYNONYMS_CAPABILITY, T as TASK_CANCEL_CAPABILITY, b as TASK_FILTER_CAPABILITY } from './capabilities-9YwwCcqP.js';
|
|
3
3
|
export { C as CapabilitiesResponse, a as CreateIndexEmbedding, H as HttpIndexConfig, I as ImportError, b as ImportResult, M as MemoryStatsResponse, T as TaskListPage, c as TaskListQuery, d as TaskProgress, e as TaskRecord, f as TaskStatus, g as TaskType } from './tasks-DLQIfXqy.js';
|
|
4
|
-
export { A as AdminOperations, B as BulkOperations, D as DocumentOperations, F as FetchFunction, I as ImportSource, a as IndexOperations, N as NarsilClient, b as NarsilClientOptions, P as PutResult, R as RequestOptions, S as SearchOperations, c as ServerOperations, d as ServerVersion, T as TaskOperations, W as WaitForTaskOptions, e as createNarsilClient } from './client-
|
|
4
|
+
export { A as AdminOperations, B as BulkOperations, D as DocumentOperations, F as FetchFunction, I as ImportSource, a as IndexOperations, N as NarsilClient, b as NarsilClientOptions, P as PutResult, R as RequestOptions, S as SearchOperations, c as ServerOperations, d as ServerVersion, T as TaskOperations, W as WaitForTaskOptions, e as createNarsilClient } from './client-CsuhZ13c.js';
|
|
5
5
|
import './schema-4W_7tk1f.js';
|
|
6
6
|
import './adapters-BQFQ4PRz.js';
|
|
7
7
|
import './synonyms-CpOAHPa-.js';
|
package/dist/client.mjs
CHANGED
|
@@ -563,6 +563,9 @@ function movesOnAfterAnswer(status, code, repeatable) {
|
|
|
563
563
|
if (!answersUnavailable(status)) return false;
|
|
564
564
|
return repeatable || code === ErrorCodes.NODE_NOT_READY;
|
|
565
565
|
}
|
|
566
|
+
function earnsExtraTry(failure) {
|
|
567
|
+
return failure.code === ClientErrorCodes.CLIENT_CONNECTION_FAILED;
|
|
568
|
+
}
|
|
566
569
|
function movesOnAfterFailure(failure, sentNothing, repeatable) {
|
|
567
570
|
if (failure.code === ClientErrorCodes.CLIENT_REQUEST_TIMEOUT) return repeatable;
|
|
568
571
|
if (failure.code === ClientErrorCodes.CLIENT_CONNECTION_FAILED) return repeatable || sentNothing;
|
|
@@ -744,30 +747,43 @@ function createTransport(options) {
|
|
|
744
747
|
if (perCall !== void 0) return perCall;
|
|
745
748
|
return options.maxResponseBytes ?? 0;
|
|
746
749
|
}
|
|
750
|
+
function recordAttempt(entry, attempt, repeatable) {
|
|
751
|
+
if (attempt.kind === "answer") {
|
|
752
|
+
if (!answersUnavailable(attempt.status)) {
|
|
753
|
+
pool.answered(entry);
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
return movesOnAfterAnswer(attempt.status, envelopeCodeOf(attempt.text), repeatable);
|
|
757
|
+
}
|
|
758
|
+
if (attempt.error.code === ClientErrorCodes.CLIENT_CONNECTION_FAILED) pool.refused(entry, Date.now());
|
|
759
|
+
return movesOnAfterFailure(attempt.error, attempt.sentNothing, repeatable);
|
|
760
|
+
}
|
|
761
|
+
function outcomeOf(attempt) {
|
|
762
|
+
if (attempt === null) throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The client holds no server address");
|
|
763
|
+
if (attempt.kind === "failure") throw attempt.error;
|
|
764
|
+
return attempt;
|
|
765
|
+
}
|
|
747
766
|
async function exchange(spec, keepsStream = false) {
|
|
748
767
|
const repeatable = spec.repeatable === true || spec.method === "GET";
|
|
749
768
|
const replayable = !(spec.body instanceof ReadableStream);
|
|
769
|
+
const tryOn = async (entry2) => {
|
|
770
|
+
pool.took(entry2);
|
|
771
|
+
return exchangeOnce(entry2.base, spec, keepsStream);
|
|
772
|
+
};
|
|
773
|
+
let triesOnceMore = repeatable && replayable;
|
|
750
774
|
let last = null;
|
|
751
|
-
for (const
|
|
752
|
-
|
|
753
|
-
const
|
|
754
|
-
if (
|
|
755
|
-
|
|
756
|
-
const code = unavailable ? envelopeCodeOf(attempt.text) : void 0;
|
|
757
|
-
if (!replayable || !movesOnAfterAnswer(attempt.status, code, repeatable)) {
|
|
758
|
-
if (!unavailable) pool.answered(entry);
|
|
759
|
-
return attempt;
|
|
760
|
-
}
|
|
761
|
-
} else {
|
|
762
|
-
if (attempt.error.code === ClientErrorCodes.CLIENT_CONNECTION_FAILED) pool.refused(entry, Date.now());
|
|
763
|
-
if (!replayable || !movesOnAfterFailure(attempt.error, attempt.sentNothing, repeatable)) throw attempt.error;
|
|
764
|
-
}
|
|
765
|
-
last = attempt;
|
|
775
|
+
for (const entry2 of pool.order(Date.now())) {
|
|
776
|
+
last = await tryOn(entry2);
|
|
777
|
+
const moves = recordAttempt(entry2, last, repeatable);
|
|
778
|
+
if (!replayable || !moves) return outcomeOf(last);
|
|
779
|
+
if (last.kind === "failure" && !earnsExtraTry(last.error)) triesOnceMore = false;
|
|
766
780
|
}
|
|
767
|
-
|
|
768
|
-
|
|
781
|
+
const [entry] = pool.order(Date.now());
|
|
782
|
+
if (triesOnceMore && entry !== void 0) {
|
|
783
|
+
last = await tryOn(entry);
|
|
784
|
+
recordAttempt(entry, last, repeatable);
|
|
769
785
|
}
|
|
770
|
-
return last;
|
|
786
|
+
return outcomeOf(last);
|
|
771
787
|
}
|
|
772
788
|
async function exchangeOnce(base, spec, keepsStream) {
|
|
773
789
|
const url = `${base}${withQuery(spec.path, spec.query)}`;
|
package/dist/react.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { e as TaskRecord, d as TaskProgress, b as ImportResult, c as TaskListQue
|
|
|
4
4
|
export { I as ImportError, f as TaskStatus, g as TaskType } from './tasks-DLQIfXqy.js';
|
|
5
5
|
import { ReactNode, ReactElement } from 'react';
|
|
6
6
|
import { N as Narsil } from './engine-Bq5wz6c1.js';
|
|
7
|
-
import { N as NarsilClient, I as ImportSource } from './client-
|
|
7
|
+
import { N as NarsilClient, I as ImportSource } from './client-CsuhZ13c.js';
|
|
8
8
|
import { A as AnyDocument } from './schema-4W_7tk1f.js';
|
|
9
9
|
import './synonyms-CpOAHPa-.js';
|
|
10
10
|
import './adapters-BQFQ4PRz.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delali/narsil",
|
|
3
|
-
"version": "0.3.1-next.
|
|
3
|
+
"version": "0.3.1-next.128",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Distributed search engine with full-text, vector, hybrid, and geosearch. One engine, embedded or on a server, with a cross-language .nrsl format.",
|
|
6
6
|
"author": "Delali (https://sondelali.com)",
|
|
@@ -271,11 +271,11 @@
|
|
|
271
271
|
}
|
|
272
272
|
},
|
|
273
273
|
"optionalDependencies": {
|
|
274
|
-
"@delali/narsil-native-darwin-arm64": "0.3.1-next.
|
|
275
|
-
"@delali/narsil-native-darwin-x64": "0.3.1-next.
|
|
276
|
-
"@delali/narsil-native-linux-arm64": "0.3.1-next.
|
|
277
|
-
"@delali/narsil-native-linux-x64": "0.3.1-next.
|
|
278
|
-
"@delali/narsil-native-win32-arm64": "0.3.1-next.
|
|
279
|
-
"@delali/narsil-native-win32-x64": "0.3.1-next.
|
|
274
|
+
"@delali/narsil-native-darwin-arm64": "0.3.1-next.128",
|
|
275
|
+
"@delali/narsil-native-darwin-x64": "0.3.1-next.128",
|
|
276
|
+
"@delali/narsil-native-linux-arm64": "0.3.1-next.128",
|
|
277
|
+
"@delali/narsil-native-linux-x64": "0.3.1-next.128",
|
|
278
|
+
"@delali/narsil-native-win32-arm64": "0.3.1-next.128",
|
|
279
|
+
"@delali/narsil-native-win32-x64": "0.3.1-next.128"
|
|
280
280
|
}
|
|
281
281
|
}
|