@delali/narsil 0.2.3-next.34 → 0.2.3-next.36
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/README.md +2 -2
- package/dist/adapters/filesystem.mjs +1 -1
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/{chunk-EMI63EXP.mjs → chunk-GB2IIJJG.mjs} +2 -0
- package/dist/{chunk-RO4EFWE6.mjs → chunk-GRWFY2HI.mjs} +10 -1
- package/dist/{chunk-36ER4WCG.mjs → chunk-JQUL2T6I.mjs} +2 -1
- package/dist/{chunk-GN7KF675.mjs → chunk-MMSWEEZT.mjs} +88 -164
- package/dist/{chunk-GODECMDT.mjs → chunk-PM52SMBT.mjs} +1 -1
- package/dist/chunk-WU2UZEVD.mjs +137 -0
- package/dist/{client-DQHB_swQ.d.ts → client-BobVnoIK.d.ts} +2 -2
- package/dist/client.d.ts +8 -4
- package/dist/client.mjs +2 -0
- package/dist/{config-ChZ7lfqc.d.ts → config-Byyl1QqH.d.ts} +2 -2
- package/dist/config-fLC4lbmg.d.ts +194 -0
- package/dist/{direct-executor-YARCDMJF.mjs → direct-executor-MSJEVPZU.mjs} +2 -2
- package/dist/distribution/coordinator/etcd.d.ts +5 -7
- package/dist/distribution/coordinator/etcd.mjs +27 -8
- package/dist/distribution/coordinator/in-memory.d.ts +2 -2
- package/dist/distribution/transport/grpc.mjs +3 -3
- package/dist/distribution/transport/in-memory.mjs +1 -1
- package/dist/distribution/transport/tcp.mjs +2 -2
- package/dist/distribution.d.ts +10 -108
- package/dist/distribution.mjs +1328 -370
- package/dist/embeddings/openai.mjs +1 -1
- package/dist/{engine-DScGlT2Z.d.ts → engine-BE45D5ZG.d.ts} +3 -3
- package/dist/index.browser.mjs +90 -24
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +5 -4
- package/dist/{options-BORJg5XB.d.ts → options-EXYFcem-.d.ts} +9 -0
- package/dist/persistence/durability/checkpoint-worker.d.ts +3 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +5 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.mjs +2 -0
- package/dist/{schema-emTQfEiX.d.ts → schema-ZRbk8BgH.d.ts} +1 -0
- package/dist/{search-CQ-9bKxo.d.ts → search-DHuXwJYk.d.ts} +29 -2
- package/dist/server.d.ts +9 -5
- package/dist/server.mjs +101 -7
- package/dist/{types-BhdINMtE.d.ts → types-B5Tsaalz.d.ts} +19 -2
- package/dist/workers/entry.mjs +2 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
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 } from './search-
|
|
2
|
-
export { A as ASYNC_IMPORT_CAPABILITY, E as ErrorEnvelope, R as REBUILD_ANALYSIS_CAPABILITY, S as SERVER_CAPABILITIES, T as TASK_CANCEL_CAPABILITY, a as TASK_FILTER_CAPABILITY } from './options-
|
|
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 } from './search-DHuXwJYk.js';
|
|
2
|
+
export { A as ASYNC_IMPORT_CAPABILITY, E as ErrorEnvelope, R as REBUILD_ANALYSIS_CAPABILITY, S as SERVER_CAPABILITIES, T as TASK_CANCEL_CAPABILITY, a as TASK_FILTER_CAPABILITY } from './options-EXYFcem-.js';
|
|
3
3
|
export { C as CapabilitiesResponse, a as CreateIndexEmbedding, H as HttpIndexConfig, I as ImportError, b as ImportResult, T as TaskListPage, c as TaskListQuery, d as TaskProgress, e as TaskRecord, f as TaskStatus, g as TaskType } from './tasks-CnMLpfk-.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-
|
|
5
|
-
import './schema-
|
|
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-BobVnoIK.js';
|
|
5
|
+
import './schema-ZRbk8BgH.js';
|
|
6
6
|
import './adapters-79OIa4xm.js';
|
|
7
|
+
import './config-fLC4lbmg.js';
|
|
8
|
+
import './config-Byyl1QqH.js';
|
|
9
|
+
import './types-B5Tsaalz.js';
|
|
10
|
+
import './types-D5OwhtsQ.js';
|
package/dist/client.mjs
CHANGED
|
@@ -53,6 +53,8 @@ var ErrorCodes = {
|
|
|
53
53
|
NODE_BOOTSTRAP_FAILED: "NODE_BOOTSTRAP_FAILED",
|
|
54
54
|
NODE_ALREADY_JOINED: "NODE_ALREADY_JOINED",
|
|
55
55
|
NODE_NOT_JOINED: "NODE_NOT_JOINED",
|
|
56
|
+
NODE_NOT_READY: "NODE_NOT_READY",
|
|
57
|
+
NODE_NOT_CONTROLLER: "NODE_NOT_CONTROLLER",
|
|
56
58
|
COORDINATOR_DEPENDENCY_MISSING: "COORDINATOR_DEPENDENCY_MISSING",
|
|
57
59
|
TRANSPORT_DEPENDENCY_MISSING: "TRANSPORT_DEPENDENCY_MISSING",
|
|
58
60
|
REPLICATION_ENTRY_INVALID: "REPLICATION_ENTRY_INVALID",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PersistenceAdapter, I as InvalidationAdapter, E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
|
|
2
|
-
import { Q as QueryParams, e as QueryResult } from './search-
|
|
3
|
-
import { I as IndexConfig, A as AnyDocument } from './schema-
|
|
2
|
+
import { Q as QueryParams, e as QueryResult } from './search-DHuXwJYk.js';
|
|
3
|
+
import { I as IndexConfig, A as AnyDocument } from './schema-ZRbk8BgH.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Hooks that run alongside the engine's own work, which is how you add
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { N as NarsilConfig } from './config-Byyl1QqH.js';
|
|
2
|
+
import { A as AllocationTable, N as NodeRole, a as NodeRegistration, C as ClusterCoordinator, b as NodeCapacity } from './types-B5Tsaalz.js';
|
|
3
|
+
import { N as NodeTransport } from './types-D5OwhtsQ.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* How much replication history a primary keeps, and how many replicas have to
|
|
7
|
+
* confirm a write before it is acknowledged.
|
|
8
|
+
*
|
|
9
|
+
* A replica that falls further behind than the retained log recovers from a
|
|
10
|
+
* whole snapshot instead of replaying entries, so a larger retention trades
|
|
11
|
+
* memory for cheaper recovery.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
interface ReplicationConfig {
|
|
16
|
+
/** A primary keeps this many bytes of replication log before it drops the oldest entries. */
|
|
17
|
+
logRetentionBytes: number;
|
|
18
|
+
/** This many replicas must acknowledge a write before the primary reports it as done. */
|
|
19
|
+
waitForActiveReplicas: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Everything {@link createClusterNode} needs to join a node to a cluster.
|
|
24
|
+
*
|
|
25
|
+
* The coordinator and the transport are the two pieces you choose: the
|
|
26
|
+
* coordinator holds the cluster's shared state, and the transport carries
|
|
27
|
+
* messages between nodes.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
interface ClusterNodeConfig {
|
|
32
|
+
/** This node reads and writes the cluster's shared state here. Every node in a cluster must point at the same one. */
|
|
33
|
+
coordinator: ClusterCoordinator;
|
|
34
|
+
/** This node reaches its peers through this transport. */
|
|
35
|
+
transport: NodeTransport;
|
|
36
|
+
/** Peers reach this node at this address, as the transport writes it. */
|
|
37
|
+
address: string;
|
|
38
|
+
/** This node holds these roles in the cluster, and holds data alone by default. */
|
|
39
|
+
roles?: NodeRole[];
|
|
40
|
+
/** This identifies the node across the cluster. The package generates an id by default, which a restart changes. */
|
|
41
|
+
nodeId?: string;
|
|
42
|
+
/** This node offers this much capacity, which the allocator weighs. It offers {@link DEFAULT_CAPACITY} by default. */
|
|
43
|
+
capacity?: NodeCapacity;
|
|
44
|
+
/** These settings configure the engine this node runs locally, such as its persistence and durability. */
|
|
45
|
+
engine?: NarsilConfig;
|
|
46
|
+
/** These replication settings override the engine's own, and anything you leave out keeps its value. */
|
|
47
|
+
replication?: Partial<ReplicationConfig>;
|
|
48
|
+
/** These settings govern how this node gathers each search from the cluster, and anything you leave out keeps its default. */
|
|
49
|
+
query?: ClusterQueryConfig;
|
|
50
|
+
/** These settings govern how this node stands for controller election, and anything you leave out keeps its default. */
|
|
51
|
+
controller?: ClusterControllerConfig;
|
|
52
|
+
/** This receives the failures the node reports while running on its own, away from any call you made. */
|
|
53
|
+
onError?: (error: Error) => void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* How long this node's turn as controller survives a fault, and how often it
|
|
57
|
+
* stands for election again.
|
|
58
|
+
*
|
|
59
|
+
* A cluster fails over no faster than the lease it grants the controller, so a
|
|
60
|
+
* demonstration lowers both figures and a busy cluster leaves them alone. Every
|
|
61
|
+
* controller-capable node in a cluster should carry the same pair.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
interface ClusterControllerConfig {
|
|
66
|
+
/**
|
|
67
|
+
* The controller lease survives this many milliseconds without a renewal, so
|
|
68
|
+
* a controller that loses the coordinator keeps its claim for that long. The
|
|
69
|
+
* active controller renews the lease every third of this, and a standby takes
|
|
70
|
+
* the lease over up to {@link ClusterControllerConfig.standbyRetryMs} after it
|
|
71
|
+
* expires. It is 15000 milliseconds where you name none.
|
|
72
|
+
*/
|
|
73
|
+
leaseTtlMs?: number;
|
|
74
|
+
/**
|
|
75
|
+
* A node that holds no lease stands for election again after this many
|
|
76
|
+
* milliseconds, whether the lease was taken or the coordinator refused the
|
|
77
|
+
* attempt. It is 5000 milliseconds where you name none.
|
|
78
|
+
*/
|
|
79
|
+
standbyRetryMs?: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* How this node answers a search when one of the nodes it asked runs slowly or
|
|
83
|
+
* drops out.
|
|
84
|
+
*
|
|
85
|
+
* The defaults let a search answer from the nodes that did reply, so set
|
|
86
|
+
* `allowPartialResults` to false where a caller must never act on an
|
|
87
|
+
* incomplete count. Every search reports what it read in
|
|
88
|
+
* {@link QueryResult.coverage} whichever way you set these.
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
interface ClusterQueryConfig {
|
|
93
|
+
/**
|
|
94
|
+
* Set this true and a search returns the hits the reachable nodes gave,
|
|
95
|
+
* counting the rest in {@link QueryResult.coverage}, which is what a node
|
|
96
|
+
* does by default. Set it false and one partition that times out, errors, or
|
|
97
|
+
* has no active copy fails the whole search with `QUERY_PARTIAL_FAILURE`.
|
|
98
|
+
*/
|
|
99
|
+
allowPartialResults?: boolean;
|
|
100
|
+
/** A search waits this many milliseconds for each node before it counts that node's partitions as timed out, which is 5000 milliseconds where you name none. */
|
|
101
|
+
partitionTimeout?: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* How an index is spread across the cluster when a node creates it.
|
|
105
|
+
*
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
interface CreateIndexOptions {
|
|
109
|
+
/** The cluster splits the index into this many partitions, and into {@link DEFAULT_PARTITION_COUNT} by default. */
|
|
110
|
+
partitionCount?: number;
|
|
111
|
+
/** The cluster keeps this many copies of each partition, and {@link DEFAULT_REPLICATION_FACTOR} by default. */
|
|
112
|
+
replicationFactor?: number;
|
|
113
|
+
/**
|
|
114
|
+
* The creation returns once every partition is in service or once this many milliseconds have passed, which is
|
|
115
|
+
* 30000 where you name none. It returns either way, so a write sent after the deadline may be refused with
|
|
116
|
+
* `QUERY_ROUTING_FAILED` while the controller is still allocating. Pass 0 to return as soon as the schema is
|
|
117
|
+
* published.
|
|
118
|
+
*/
|
|
119
|
+
waitForServingMs?: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Where a node stands between starting and shutting down, which is what a
|
|
123
|
+
* readiness probe reads.
|
|
124
|
+
*
|
|
125
|
+
* A node reports `STARTING` until it holds a registration. It reports
|
|
126
|
+
* `JOINING` while it bootstraps a partition the controller gave it, and
|
|
127
|
+
* `SERVING` once it serves every one of them. It reports `LEAVING` from the
|
|
128
|
+
* moment shutdown begins.
|
|
129
|
+
*
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
type NodeReadiness = 'STARTING' | 'JOINING' | 'SERVING' | 'LEAVING';
|
|
133
|
+
/**
|
|
134
|
+
* The cluster-facing side of a node, which is where you look at the cluster
|
|
135
|
+
* rather than at the data.
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
interface ClusterNamespace {
|
|
140
|
+
/**
|
|
141
|
+
* Reads how one index is spread across the cluster.
|
|
142
|
+
*
|
|
143
|
+
* @param indexName - The index to describe.
|
|
144
|
+
* @returns Its allocation, or `null` when the index has none yet.
|
|
145
|
+
*/
|
|
146
|
+
getAllocation(indexName: string): Promise<AllocationTable | null>;
|
|
147
|
+
/**
|
|
148
|
+
* Describes this node.
|
|
149
|
+
*
|
|
150
|
+
* @returns Its id, its roles, and where it stands.
|
|
151
|
+
*/
|
|
152
|
+
getNodeInfo(): ClusterNodeInfo;
|
|
153
|
+
/**
|
|
154
|
+
* Reports whether this node is the cluster's active controller, which is the
|
|
155
|
+
* one node making allocation decisions.
|
|
156
|
+
*
|
|
157
|
+
* @returns True while this node holds the controller lease.
|
|
158
|
+
*/
|
|
159
|
+
isControllerActive(): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Reports whether this node serves work, which is what a readiness probe
|
|
162
|
+
* answers with.
|
|
163
|
+
*
|
|
164
|
+
* @returns The node's readiness as it stands.
|
|
165
|
+
*/
|
|
166
|
+
getReadiness(): NodeReadiness;
|
|
167
|
+
/**
|
|
168
|
+
* Lists the nodes the coordinator holds a registration for.
|
|
169
|
+
*
|
|
170
|
+
* @returns One registration per node, as each node published it.
|
|
171
|
+
*/
|
|
172
|
+
listNodes(): Promise<NodeRegistration[]>;
|
|
173
|
+
/**
|
|
174
|
+
* Names the node holding the controller lease.
|
|
175
|
+
*
|
|
176
|
+
* @returns Its id, or `null` while no node holds the lease.
|
|
177
|
+
*/
|
|
178
|
+
getControllerNodeId(): Promise<string | null>;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* What one node reports about itself.
|
|
182
|
+
*
|
|
183
|
+
* @public
|
|
184
|
+
*/
|
|
185
|
+
interface ClusterNodeInfo {
|
|
186
|
+
/** This identifies the node across the cluster. */
|
|
187
|
+
nodeId: string;
|
|
188
|
+
/** The node holds these roles in the cluster. */
|
|
189
|
+
roles: ReadonlyArray<NodeRole>;
|
|
190
|
+
/** This says where the node stands, from joining through to shut down. */
|
|
191
|
+
status: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export type { ClusterNamespace as C, NodeReadiness as N, ReplicationConfig as R, CreateIndexOptions as a, ClusterNodeConfig as b, ClusterControllerConfig as c, ClusterNodeInfo as d, ClusterQueryConfig as e };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { createDirectExecutor } from './chunk-
|
|
1
|
+
export { createDirectExecutor } from './chunk-GRWFY2HI.mjs';
|
|
2
2
|
import './chunk-TGP5M5R7.mjs';
|
|
3
3
|
import './chunk-OBXS7OZM.mjs';
|
|
4
4
|
import './chunk-WDL632CN.mjs';
|
|
5
5
|
import './chunk-U2BKYEC7.mjs';
|
|
6
6
|
import './chunk-BFIH7OV5.mjs';
|
|
7
7
|
import './chunk-WTONLDU3.mjs';
|
|
8
|
-
import './chunk-
|
|
8
|
+
import './chunk-GB2IIJJG.mjs';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as ClusterCoordinator } from '../../types-
|
|
2
|
-
import '../../schema-
|
|
1
|
+
import { C as ClusterCoordinator } from '../../types-B5Tsaalz.js';
|
|
2
|
+
import '../../schema-ZRbk8BgH.js';
|
|
3
3
|
import '../../adapters-79OIa4xm.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* How {@link createEtcdCoordinator} reaches etcd, and how long
|
|
7
|
-
*
|
|
6
|
+
* How {@link createEtcdCoordinator} reaches etcd, and how long a node's
|
|
7
|
+
* registration survives there.
|
|
8
8
|
*
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
@@ -15,8 +15,6 @@ interface EtcdCoordinatorConfig {
|
|
|
15
15
|
keyPrefix: string;
|
|
16
16
|
/** A node's registration survives this many seconds without a heartbeat, after which peers treat the node as gone. */
|
|
17
17
|
nodeHeartbeatTtlSeconds: number;
|
|
18
|
-
/** The controller lease survives this many seconds without renewal, which is how long a failover takes at worst. */
|
|
19
|
-
leaseTtlSeconds: number;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
/**
|
|
@@ -44,7 +42,7 @@ declare function validateNodeId(nodeId: string): void;
|
|
|
44
42
|
* controllers from disagreeing. Install `etcd3` alongside this package,
|
|
45
43
|
* because it is an optional peer dependency this call loads on demand.
|
|
46
44
|
*
|
|
47
|
-
* @param config - Endpoints, key prefix, and
|
|
45
|
+
* @param config - Endpoints, key prefix, and heartbeat lifetime to override.
|
|
48
46
|
* Anything you leave out keeps its default.
|
|
49
47
|
* @returns A coordinator you pass as a cluster node's `coordinator`.
|
|
50
48
|
* @throws A `NarsilError` with `COORDINATOR_DEPENDENCY_MISSING` when `etcd3`
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { compareCodePoints } from '../../chunk-BFIH7OV5.mjs';
|
|
2
|
-
import { NarsilError, ErrorCodes } from '../../chunk-
|
|
2
|
+
import { NarsilError, ErrorCodes } from '../../chunk-GB2IIJJG.mjs';
|
|
3
3
|
import { decode, encode } from '@msgpack/msgpack';
|
|
4
4
|
|
|
5
5
|
// src/distribution/coordinator/etcd/types.ts
|
|
6
6
|
var DEFAULT_ETCD_CONFIG = {
|
|
7
7
|
endpoints: ["http://localhost:2379"],
|
|
8
8
|
keyPrefix: "_narsil",
|
|
9
|
-
nodeHeartbeatTtlSeconds: 30
|
|
10
|
-
leaseTtlSeconds: 15
|
|
9
|
+
nodeHeartbeatTtlSeconds: 30
|
|
11
10
|
};
|
|
12
11
|
var ETCD_KEY_NODES = "nodes";
|
|
13
12
|
var ETCD_KEY_ALLOCATION = "allocation";
|
|
@@ -149,6 +148,19 @@ function deserializeAllocationTable(data) {
|
|
|
149
148
|
assignments: normaliseAssignments(raw.assignments)
|
|
150
149
|
};
|
|
151
150
|
}
|
|
151
|
+
function stringsOf(value) {
|
|
152
|
+
if (!Array.isArray(value)) {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
return value.filter((entry) => typeof entry === "string");
|
|
156
|
+
}
|
|
157
|
+
function normaliseLastHolders(candidate) {
|
|
158
|
+
const stored = stringsOf(candidate.lastHolders);
|
|
159
|
+
if (stored.length > 0 || Array.isArray(candidate.lastHolders)) {
|
|
160
|
+
return stored;
|
|
161
|
+
}
|
|
162
|
+
return candidate.state === "UNASSIGNED" ? stringsOf(candidate.inSyncSet) : [];
|
|
163
|
+
}
|
|
152
164
|
function normaliseAssignments(entries) {
|
|
153
165
|
const assignments = /* @__PURE__ */ new Map();
|
|
154
166
|
for (const pair of entries) {
|
|
@@ -162,7 +174,14 @@ function normaliseAssignments(entries) {
|
|
|
162
174
|
const candidate = assignment;
|
|
163
175
|
const storedCommitPoint = candidate.commitPoint;
|
|
164
176
|
const commitPoint = typeof storedCommitPoint === "number" && Number.isSafeInteger(storedCommitPoint) && storedCommitPoint >= 0 ? storedCommitPoint : 0;
|
|
165
|
-
|
|
177
|
+
const lastHolders = normaliseLastHolders(candidate);
|
|
178
|
+
const normalised = { ...assignment, commitPoint };
|
|
179
|
+
if (lastHolders.length > 0) {
|
|
180
|
+
normalised.lastHolders = lastHolders;
|
|
181
|
+
} else {
|
|
182
|
+
delete normalised.lastHolders;
|
|
183
|
+
}
|
|
184
|
+
assignments.set(partitionId, normalised);
|
|
166
185
|
}
|
|
167
186
|
return assignments;
|
|
168
187
|
}
|
|
@@ -450,11 +469,11 @@ async function createEtcdCoordinator(config) {
|
|
|
450
469
|
assertNotShutdown();
|
|
451
470
|
const etcdKey = keys.lease(key);
|
|
452
471
|
const entry = leaseManager.remove(etcdKey);
|
|
453
|
-
if (entry
|
|
454
|
-
|
|
455
|
-
});
|
|
472
|
+
if (entry === void 0) {
|
|
473
|
+
return;
|
|
456
474
|
}
|
|
457
|
-
await
|
|
475
|
+
await entry.lease.revoke().catch(() => {
|
|
476
|
+
});
|
|
458
477
|
},
|
|
459
478
|
async get(key) {
|
|
460
479
|
assertNotShutdown();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { decodeTransportMessage, encodeTransportMessage } from '../../chunk-
|
|
2
|
-
import { TransportError, TransportErrorCodes, MAX_MESSAGE_SIZE_BYTES } from '../../chunk-
|
|
3
|
-
import { NarsilError, ErrorCodes } from '../../chunk-
|
|
1
|
+
import { decodeTransportMessage, encodeTransportMessage } from '../../chunk-PM52SMBT.mjs';
|
|
2
|
+
import { TransportError, TransportErrorCodes, MAX_MESSAGE_SIZE_BYTES } from '../../chunk-JQUL2T6I.mjs';
|
|
3
|
+
import { NarsilError, ErrorCodes } from '../../chunk-GB2IIJJG.mjs';
|
|
4
4
|
|
|
5
5
|
// src/distribution/transport/grpc/codec.ts
|
|
6
6
|
var FIELD_ONE_LENGTH_DELIMITED_KEY = 10;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_TRANSPORT_CONFIG, TransportError, TransportErrorCodes, MAX_MESSAGE_SIZE_BYTES } from '../../chunk-
|
|
1
|
+
import { DEFAULT_TRANSPORT_CONFIG, TransportError, TransportErrorCodes, MAX_MESSAGE_SIZE_BYTES } from '../../chunk-JQUL2T6I.mjs';
|
|
2
2
|
|
|
3
3
|
// src/distribution/transport/in-memory.ts
|
|
4
4
|
function createInMemoryNetwork() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DEFAULT_TCP_CONFIG, encodeTransportMessage, encodeFrame, FRAME_TYPE_REQUEST, FrameParser, FRAME_TYPE_RESPONSE, decodeTransportMessage, FRAME_TYPE_STREAM_CHUNK, FRAME_TYPE_STREAM_END } from '../../chunk-
|
|
2
|
-
import { MAX_MESSAGE_SIZE_BYTES, TransportError, TransportErrorCodes } from '../../chunk-
|
|
1
|
+
import { DEFAULT_TCP_CONFIG, encodeTransportMessage, encodeFrame, FRAME_TYPE_REQUEST, FrameParser, FRAME_TYPE_RESPONSE, decodeTransportMessage, FRAME_TYPE_STREAM_CHUNK, FRAME_TYPE_STREAM_END } from '../../chunk-PM52SMBT.mjs';
|
|
2
|
+
import { MAX_MESSAGE_SIZE_BYTES, TransportError, TransportErrorCodes } from '../../chunk-JQUL2T6I.mjs';
|
|
3
3
|
import { connect as connect$1, createServer as createServer$1 } from 'net';
|
|
4
4
|
import { connect, createServer } from 'tls';
|
|
5
5
|
|
package/dist/distribution.d.ts
CHANGED
|
@@ -1,112 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { a as CreateIndexOptions, C as ClusterNamespace, b as ClusterNodeConfig } from './config-fLC4lbmg.js';
|
|
2
|
+
export { c as ClusterControllerConfig, d as ClusterNodeInfo, e as ClusterQueryConfig, N as NodeReadiness, R as ReplicationConfig } from './config-fLC4lbmg.js';
|
|
3
|
+
import { N as NarsilEventMap, a as Narsil } from './engine-BE45D5ZG.js';
|
|
4
|
+
import { B as BatchResult, L as ListParams, g as ListResult, i as SuggestParams, j as SuggestResult, Q as QueryParams, h as PreflightResult, f as IndexStats, P as PartitionStatsResult, M as MemoryStats, e as QueryResult } from './search-DHuXwJYk.js';
|
|
5
|
+
import { I as IndexConfig, A as AnyDocument, a as InsertOptions } from './schema-ZRbk8BgH.js';
|
|
6
|
+
import { b as NodeCapacity, N as NodeRole } from './types-B5Tsaalz.js';
|
|
7
|
+
export { c as AllocationConstraints, d as AllocationEvent, A as AllocationTable, C as ClusterCoordinator, e as NodeEvent, a as NodeRegistration, P as PartitionAssignment, f as PartitionState, S as SchemaEvent, U as UnassignedReason } from './types-B5Tsaalz.js';
|
|
8
|
+
export { L as ListenHandler, N as NodeTransport, R as RespondFn, T as TransportConfig, a as TransportMessage } from './types-D5OwhtsQ.js';
|
|
9
|
+
import './config-Byyl1QqH.js';
|
|
9
10
|
import './adapters-79OIa4xm.js';
|
|
10
11
|
|
|
11
|
-
/**
|
|
12
|
-
* How much replication history a primary keeps, and how many replicas have to
|
|
13
|
-
* confirm a write before it is acknowledged.
|
|
14
|
-
*
|
|
15
|
-
* A replica that falls further behind than the retained log recovers from a
|
|
16
|
-
* whole snapshot instead of replaying entries, so a larger retention trades
|
|
17
|
-
* memory for cheaper recovery.
|
|
18
|
-
*
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
interface ReplicationConfig {
|
|
22
|
-
/** A primary keeps this many bytes of replication log before it drops the oldest entries. */
|
|
23
|
-
logRetentionBytes: number;
|
|
24
|
-
/** This many replicas must acknowledge a write before the primary reports it as done. */
|
|
25
|
-
waitForActiveReplicas: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Everything {@link createClusterNode} needs to join a node to a cluster.
|
|
30
|
-
*
|
|
31
|
-
* The coordinator and the transport are the two pieces you choose: the
|
|
32
|
-
* coordinator holds the cluster's shared state, and the transport carries
|
|
33
|
-
* messages between nodes.
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
interface ClusterNodeConfig {
|
|
38
|
-
/** This node reads and writes the cluster's shared state here. Every node in a cluster must point at the same one. */
|
|
39
|
-
coordinator: ClusterCoordinator;
|
|
40
|
-
/** This node reaches its peers through this transport. */
|
|
41
|
-
transport: NodeTransport;
|
|
42
|
-
/** Peers reach this node at this address, as the transport writes it. */
|
|
43
|
-
address: string;
|
|
44
|
-
/** This node holds these roles in the cluster, and holds data alone by default. */
|
|
45
|
-
roles?: NodeRole[];
|
|
46
|
-
/** This identifies the node across the cluster. The package generates an id by default, which a restart changes. */
|
|
47
|
-
nodeId?: string;
|
|
48
|
-
/** This node offers this much capacity, which the allocator weighs. It offers {@link DEFAULT_CAPACITY} by default. */
|
|
49
|
-
capacity?: NodeCapacity;
|
|
50
|
-
/** These settings configure the engine this node runs locally, such as its persistence and durability. */
|
|
51
|
-
engine?: NarsilConfig;
|
|
52
|
-
/** These replication settings override the engine's own, and anything you leave out keeps its value. */
|
|
53
|
-
replication?: Partial<ReplicationConfig>;
|
|
54
|
-
/** This receives the failures the node reports while running on its own, away from any call you made. */
|
|
55
|
-
onError?: (error: Error) => void;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* How an index is spread across the cluster when a node creates it.
|
|
59
|
-
*
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
interface CreateIndexOptions {
|
|
63
|
-
/** The cluster splits the index into this many partitions, and into {@link DEFAULT_PARTITION_COUNT} by default. */
|
|
64
|
-
partitionCount?: number;
|
|
65
|
-
/** The cluster keeps this many copies of each partition, and {@link DEFAULT_REPLICATION_FACTOR} by default. */
|
|
66
|
-
replicationFactor?: number;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* The cluster-facing side of a node, which is where you look at the cluster
|
|
70
|
-
* rather than at the data.
|
|
71
|
-
*
|
|
72
|
-
* @public
|
|
73
|
-
*/
|
|
74
|
-
interface ClusterNamespace {
|
|
75
|
-
/**
|
|
76
|
-
* Reads how one index is spread across the cluster.
|
|
77
|
-
*
|
|
78
|
-
* @param indexName - The index to describe.
|
|
79
|
-
* @returns Its allocation, or `null` when the index has none yet.
|
|
80
|
-
*/
|
|
81
|
-
getAllocation(indexName: string): Promise<AllocationTable | null>;
|
|
82
|
-
/**
|
|
83
|
-
* Describes this node.
|
|
84
|
-
*
|
|
85
|
-
* @returns Its id, its roles, and where it stands.
|
|
86
|
-
*/
|
|
87
|
-
getNodeInfo(): ClusterNodeInfo;
|
|
88
|
-
/**
|
|
89
|
-
* Reports whether this node is the cluster's active controller, which is the
|
|
90
|
-
* one node making allocation decisions.
|
|
91
|
-
*
|
|
92
|
-
* @returns True while this node holds the controller lease.
|
|
93
|
-
*/
|
|
94
|
-
isControllerActive(): boolean;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* What one node reports about itself.
|
|
98
|
-
*
|
|
99
|
-
* @public
|
|
100
|
-
*/
|
|
101
|
-
interface ClusterNodeInfo {
|
|
102
|
-
/** This identifies the node across the cluster. */
|
|
103
|
-
nodeId: string;
|
|
104
|
-
/** The node holds these roles in the cluster. */
|
|
105
|
-
roles: ReadonlyArray<NodeRole>;
|
|
106
|
-
/** This says where the node stands, from joining through to shut down. */
|
|
107
|
-
status: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
12
|
/**
|
|
111
13
|
* The cluster splits an index into this many partitions when
|
|
112
14
|
* {@link CreateIndexOptions} names no count.
|
|
@@ -441,4 +343,4 @@ interface ClusterEngineOptions {
|
|
|
441
343
|
*/
|
|
442
344
|
declare function clusterNodeEngine(node: ClusterNode, options?: ClusterEngineOptions): Narsil;
|
|
443
345
|
|
|
444
|
-
export {
|
|
346
|
+
export { type ClusterEngineOptions, ClusterNamespace, type ClusterNode, ClusterNodeConfig, CreateIndexOptions, DEFAULT_CAPACITY, DEFAULT_PARTITION_COUNT, DEFAULT_REPLICATION_FACTOR, NodeCapacity, NodeRole, clusterNodeEngine, createClusterNode };
|