@delali/narsil 0.2.0 → 0.2.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/dist/adapters/filesystem.d.ts +23 -1
- package/dist/adapters/filesystem.mjs +1 -1
- package/dist/adapters/indexeddb.d.ts +25 -1
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/adapters/memory.d.ts +14 -1
- package/dist/adapters-CVqI5NBt.d.ts +149 -0
- package/dist/{chunk-S6IAXOBA.mjs → chunk-ASI6AOW2.mjs} +1 -1
- package/dist/{chunk-AUMKFYTG.mjs → chunk-FKK76OR7.mjs} +56 -55
- package/dist/{chunk-M2EDG55Y.mjs → chunk-UNJZ7ZDB.mjs} +10 -0
- package/dist/{chunk-XAKNSWIK.mjs → chunk-WLR5BFL3.mjs} +16 -14
- package/dist/config-CAjTHzkH.d.ts +256 -0
- package/dist/{direct-executor-2FV3MEDD.mjs → direct-executor-3W4QRA4E.mjs} +2 -2
- package/dist/distribution/coordinator/etcd.d.ts +44 -3
- package/dist/distribution/coordinator/etcd.mjs +2 -2
- package/dist/distribution/coordinator/in-memory.d.ts +14 -3
- package/dist/distribution.d.ts +312 -45
- package/dist/distribution.mjs +4 -4
- package/dist/embeddings/openai.d.ts +28 -1
- package/dist/embeddings/openai.mjs +1 -1
- package/dist/engine-CCrlfLyq.d.ts +431 -0
- package/dist/index.browser.mjs +24 -12
- package/dist/index.d.ts +173 -8
- package/dist/index.mjs +3 -3
- package/dist/invalidation/broadcast-channel.d.ts +20 -1
- package/dist/invalidation/filesystem.d.ts +24 -1
- package/dist/invalidation/noop.d.ts +14 -1
- package/dist/language-DB8KG1z5.d.ts +53 -0
- package/dist/languages/albanian.d.ts +11 -1
- package/dist/languages/amharic.d.ts +11 -1
- package/dist/languages/arabic.d.ts +10 -1
- package/dist/languages/armenian.d.ts +10 -1
- package/dist/languages/azerbaijani.d.ts +11 -1
- package/dist/languages/bambara.d.ts +11 -1
- package/dist/languages/basque.d.ts +10 -1
- package/dist/languages/belarusian.d.ts +11 -1
- package/dist/languages/bengali.d.ts +11 -1
- package/dist/languages/bosnian.d.ts +11 -1
- package/dist/languages/breton.d.ts +11 -1
- package/dist/languages/bulgarian.d.ts +10 -1
- package/dist/languages/burmese.d.ts +11 -1
- package/dist/languages/catalan.d.ts +10 -1
- package/dist/languages/chinese.d.ts +11 -1
- package/dist/languages/croatian.d.ts +11 -1
- package/dist/languages/czech.d.ts +10 -1
- package/dist/languages/dagbani.d.ts +11 -1
- package/dist/languages/danish.d.ts +10 -1
- package/dist/languages/dutch.d.ts +10 -1
- package/dist/languages/english.d.ts +10 -1
- package/dist/languages/esperanto.d.ts +10 -1
- package/dist/languages/estonian.d.ts +10 -1
- package/dist/languages/ewe.d.ts +11 -1
- package/dist/languages/faroese.d.ts +11 -1
- package/dist/languages/fijian.d.ts +11 -1
- package/dist/languages/finnish.d.ts +10 -1
- package/dist/languages/french.d.ts +10 -1
- package/dist/languages/ga.d.ts +11 -1
- package/dist/languages/galician.d.ts +11 -1
- package/dist/languages/georgian.d.ts +11 -1
- package/dist/languages/german.d.ts +10 -1
- package/dist/languages/greek.d.ts +10 -1
- package/dist/languages/guarani.d.ts +11 -1
- package/dist/languages/gujarati.d.ts +11 -1
- package/dist/languages/haitian-creole.d.ts +11 -1
- package/dist/languages/hausa.d.ts +11 -1
- package/dist/languages/hawaiian.d.ts +11 -1
- package/dist/languages/hebrew.d.ts +11 -1
- package/dist/languages/hindi.d.ts +10 -1
- package/dist/languages/hungarian.d.ts +10 -1
- package/dist/languages/icelandic.d.ts +11 -1
- package/dist/languages/igbo.d.ts +11 -1
- package/dist/languages/indonesian.d.ts +10 -1
- package/dist/languages/irish.d.ts +10 -1
- package/dist/languages/italian.d.ts +10 -1
- package/dist/languages/japanese.d.ts +11 -1
- package/dist/languages/kannada.d.ts +11 -1
- package/dist/languages/kazakh.d.ts +11 -1
- package/dist/languages/khmer.d.ts +11 -1
- package/dist/languages/kinyarwanda.d.ts +11 -1
- package/dist/languages/kirundi.d.ts +11 -1
- package/dist/languages/korean.d.ts +11 -1
- package/dist/languages/kurmanji.d.ts +11 -1
- package/dist/languages/kyrgyz.d.ts +11 -1
- package/dist/languages/lao.d.ts +11 -1
- package/dist/languages/latin.d.ts +11 -1
- package/dist/languages/latvian.d.ts +11 -1
- package/dist/languages/lingala.d.ts +11 -1
- package/dist/languages/lithuanian.d.ts +10 -1
- package/dist/languages/luxembourgish.d.ts +11 -1
- package/dist/languages/macedonian.d.ts +11 -1
- package/dist/languages/malagasy.d.ts +11 -1
- package/dist/languages/malay.d.ts +11 -1
- package/dist/languages/malayalam.d.ts +11 -1
- package/dist/languages/maltese.d.ts +11 -1
- package/dist/languages/maori.d.ts +11 -1
- package/dist/languages/marathi.d.ts +11 -1
- package/dist/languages/nepali.d.ts +10 -1
- package/dist/languages/norwegian.d.ts +10 -1
- package/dist/languages/oromo.d.ts +11 -1
- package/dist/languages/persian.d.ts +10 -1
- package/dist/languages/polish.d.ts +10 -1
- package/dist/languages/portuguese.d.ts +10 -1
- package/dist/languages/punjabi.d.ts +11 -1
- package/dist/languages/romanian.d.ts +10 -1
- package/dist/languages/russian.d.ts +10 -1
- package/dist/languages/samoan.d.ts +11 -1
- package/dist/languages/sanskrit.d.ts +10 -1
- package/dist/languages/scottish-gaelic.d.ts +11 -1
- package/dist/languages/serbian.d.ts +10 -1
- package/dist/languages/shona.d.ts +11 -1
- package/dist/languages/sinhala.d.ts +11 -1
- package/dist/languages/slovak.d.ts +11 -1
- package/dist/languages/slovenian.d.ts +10 -1
- package/dist/languages/sorani.d.ts +11 -1
- package/dist/languages/spanish.d.ts +10 -1
- package/dist/languages/swahili.d.ts +10 -1
- package/dist/languages/swedish.d.ts +10 -1
- package/dist/languages/tagalog.d.ts +11 -1
- package/dist/languages/tamil.d.ts +10 -1
- package/dist/languages/tatar.d.ts +11 -1
- package/dist/languages/telugu.d.ts +11 -1
- package/dist/languages/thai.d.ts +11 -1
- package/dist/languages/tibetan.d.ts +11 -1
- package/dist/languages/tigrinya.d.ts +11 -1
- package/dist/languages/tongan.d.ts +11 -1
- package/dist/languages/turkish.d.ts +10 -1
- package/dist/languages/twi.d.ts +11 -1
- package/dist/languages/ukrainian.d.ts +10 -1
- package/dist/languages/urdu.d.ts +11 -1
- package/dist/languages/vietnamese.d.ts +11 -1
- package/dist/languages/welsh.d.ts +11 -1
- package/dist/languages/wolof.d.ts +11 -1
- package/dist/languages/xhosa.d.ts +11 -1
- package/dist/languages/yoruba.d.ts +11 -1
- package/dist/languages/zulu.d.ts +11 -1
- package/dist/persistence/durability/checkpoint-worker.d.ts +2 -2
- package/dist/persistence/durability/checkpoint-worker.mjs +3 -3
- package/dist/schema-CE6S_aAr.d.ts +208 -0
- package/dist/search-CgQQIciB.d.ts +786 -0
- package/dist/server.d.ts +213 -12
- package/dist/server.mjs +29 -1
- package/dist/types-BV3nAKTL.d.ts +302 -0
- package/dist/vector/hnsw-build-worker.d.ts +68 -2
- package/dist/vector/hnsw-build-worker.mjs +0 -2
- package/dist/workers/entry.mjs +1 -1
- package/package.json +5 -2
- package/dist/adapters-Bo2JQg8b.d.ts +0 -37
- package/dist/config-P27AtSn4.d.ts +0 -502
- package/dist/language-CmJBHf1j.d.ts +0 -17
- package/dist/narsil-CMZRPDlQ.d.ts +0 -159
- package/dist/schema-BnvLvjRp.d.ts +0 -67
- package/dist/types-BRTcBgAp.d.ts +0 -73
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { b as PersistenceAdapter, I as InvalidationAdapter, E as EmbeddingAdapter } from './adapters-CVqI5NBt.js';
|
|
2
|
+
import { Q as QueryParams, q as QueryResult } from './search-CgQQIciB.js';
|
|
3
|
+
import { I as IndexConfig, A as AnyDocument } from './schema-CE6S_aAr.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hooks that run alongside the engine's own work, which is how you add
|
|
7
|
+
* validation, auditing, enrichment, or metrics without forking the engine.
|
|
8
|
+
*
|
|
9
|
+
* Every hook is optional. A `before` hook runs first and rejects the operation
|
|
10
|
+
* by throwing; an `after` hook runs once the operation succeeds. The engine
|
|
11
|
+
* awaits a hook that returns a promise, so slow work in one slows every write
|
|
12
|
+
* or search it covers.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
interface NarsilPlugin {
|
|
17
|
+
/** This name identifies the plugin in errors and in event payloads. */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Runs before a document is indexed. Throw to reject the write. */
|
|
20
|
+
beforeInsert?(ctx: InsertContext): void | Promise<void>;
|
|
21
|
+
/** Runs once a document is indexed. */
|
|
22
|
+
afterInsert?(ctx: InsertContext): void | Promise<void>;
|
|
23
|
+
/** Runs before a document is removed. Throw to reject the removal. */
|
|
24
|
+
beforeRemove?(ctx: RemoveContext): void | Promise<void>;
|
|
25
|
+
/** Runs once a document is removed. */
|
|
26
|
+
afterRemove?(ctx: RemoveContext): void | Promise<void>;
|
|
27
|
+
/** Runs before a document is replaced. Throw to reject the update. */
|
|
28
|
+
beforeUpdate?(ctx: UpdateContext): void | Promise<void>;
|
|
29
|
+
/** Runs once a document is replaced. */
|
|
30
|
+
afterUpdate?(ctx: UpdateContext): void | Promise<void>;
|
|
31
|
+
/** Runs before a search executes. Throw to reject the query. */
|
|
32
|
+
beforeSearch?(ctx: SearchContext): void | Promise<void>;
|
|
33
|
+
/** Runs once a search returns, with the results on the context. */
|
|
34
|
+
afterSearch?(ctx: SearchContext): void | Promise<void>;
|
|
35
|
+
/** Runs once an index is created. */
|
|
36
|
+
onIndexCreate?(ctx: IndexContext): void | Promise<void>;
|
|
37
|
+
/** Runs once an index is dropped. */
|
|
38
|
+
onIndexDrop?(ctx: IndexContext): void | Promise<void>;
|
|
39
|
+
/** Runs once an index grows into another partition. */
|
|
40
|
+
onPartitionSplit?(ctx: PartitionContext): void | Promise<void>;
|
|
41
|
+
/** Runs once the engine moves its indexes onto worker threads. */
|
|
42
|
+
onWorkerPromote?(ctx: WorkerContext): void | Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What a plugin receives around an insert.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
interface InsertContext {
|
|
50
|
+
/** The engine writes the document to this index. */
|
|
51
|
+
indexName: string;
|
|
52
|
+
/** The document is stored under this id, which the engine resolves before the `before` hook runs. */
|
|
53
|
+
docId: string;
|
|
54
|
+
/** This is the document itself, and the engine indexes whatever a `before` hook leaves here. */
|
|
55
|
+
document: AnyDocument;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* What a plugin receives around a removal.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
interface RemoveContext {
|
|
63
|
+
/** The engine removes the document from this index. */
|
|
64
|
+
indexName: string;
|
|
65
|
+
/** This document is being removed. */
|
|
66
|
+
docId: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* What a plugin receives around an update.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
interface UpdateContext {
|
|
74
|
+
/** The document belongs to this index. */
|
|
75
|
+
indexName: string;
|
|
76
|
+
/** This document is being replaced. */
|
|
77
|
+
docId: string;
|
|
78
|
+
/** The index stored this document before the update. */
|
|
79
|
+
oldDocument: AnyDocument;
|
|
80
|
+
/** This document replaces it, and the engine indexes whatever a `before` hook leaves here. */
|
|
81
|
+
newDocument: AnyDocument;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* What a plugin receives around a search.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
interface SearchContext {
|
|
89
|
+
/** The search runs against this index. */
|
|
90
|
+
indexName: string;
|
|
91
|
+
/** These are the parameters the query runs with, and a `before` hook that changes them rewrites the search. */
|
|
92
|
+
params: QueryParams;
|
|
93
|
+
/** These are the results, which an `after` hook alone receives. */
|
|
94
|
+
results?: QueryResult;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* What a plugin receives when an index is created or dropped.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
interface IndexContext {
|
|
102
|
+
/** This index is being created or dropped. */
|
|
103
|
+
indexName: string;
|
|
104
|
+
/** The index was created with this configuration. */
|
|
105
|
+
config: IndexConfig;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* What a plugin receives when an index grows into another partition.
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
interface PartitionContext {
|
|
113
|
+
/** This index grew. */
|
|
114
|
+
indexName: string;
|
|
115
|
+
/** The index held this many partitions before. */
|
|
116
|
+
oldPartitionCount: number;
|
|
117
|
+
/** The index holds this many partitions now. */
|
|
118
|
+
newPartitionCount: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* What a plugin receives when the engine moves onto worker threads.
|
|
122
|
+
*
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
interface WorkerContext {
|
|
126
|
+
/** The pool started with this many workers. */
|
|
127
|
+
workerCount: number;
|
|
128
|
+
/** The engine promoted for this reason, such as the threshold the index passed. */
|
|
129
|
+
reason: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Everything {@link createNarsil} accepts when it builds an engine.
|
|
134
|
+
*
|
|
135
|
+
* Every field is optional, and an engine created without any of them keeps
|
|
136
|
+
* its indexes in memory alone. Add persistence to survive a restart, add
|
|
137
|
+
* invalidation to share a store with another process, and add durability to
|
|
138
|
+
* recover the writes made since the last snapshot.
|
|
139
|
+
*
|
|
140
|
+
* @public
|
|
141
|
+
*/
|
|
142
|
+
interface NarsilConfig {
|
|
143
|
+
/** This adapter writes partitions somewhere they outlive the process. */
|
|
144
|
+
persistence?: PersistenceAdapter;
|
|
145
|
+
/** This channel carries partition changes to other instances sharing the store. */
|
|
146
|
+
invalidation?: InvalidationAdapter;
|
|
147
|
+
/** These hooks observe or reject writes, searches, and lifecycle changes. */
|
|
148
|
+
plugins?: NarsilPlugin[];
|
|
149
|
+
/** This supplies the id for a document inserted without one. The engine generates a UUID v7 by default. */
|
|
150
|
+
idGenerator?: () => string;
|
|
151
|
+
/** These settings control when the engine moves its indexes onto worker threads, and how many it uses. */
|
|
152
|
+
workers?: WorkerConfig;
|
|
153
|
+
/** Every index uses this adapter unless its own config names another. */
|
|
154
|
+
embedding?: EmbeddingAdapter;
|
|
155
|
+
/** Named adapters; names persist in index metadata so recovery can rebind. */
|
|
156
|
+
embeddingAdapters?: Record<string, EmbeddingAdapter>;
|
|
157
|
+
/** These settings recover the writes made since the last snapshot. */
|
|
158
|
+
durability?: DurabilityConfig;
|
|
159
|
+
/** These settings control what the engine does when an index's stored analysis differs from its language module. */
|
|
160
|
+
analysis?: AnalysisConfig;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Describes an index whose stored terms came from an older analysis than the
|
|
164
|
+
* one its language module carries today.
|
|
165
|
+
*
|
|
166
|
+
* The engine hands this to {@link AnalysisConfig.onStaleAnalysis} together
|
|
167
|
+
* with the rebuild that fixes it, so you decide when the work runs.
|
|
168
|
+
*
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
interface StaleAnalysis {
|
|
172
|
+
/** This index holds terms that are out of date. */
|
|
173
|
+
indexName: string;
|
|
174
|
+
/** The index was built with this language module. */
|
|
175
|
+
language: string;
|
|
176
|
+
/** The index recorded this revision when it was written, and `null` for an index written before revisions existed. */
|
|
177
|
+
storedRevision: string | null;
|
|
178
|
+
/** The language module carries this revision now. */
|
|
179
|
+
currentRevision: string;
|
|
180
|
+
/** The rebuild reindexes this many documents. */
|
|
181
|
+
documentCount: number;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* What the engine does when an index's stored terms no longer match the
|
|
185
|
+
* analysis its language module produces.
|
|
186
|
+
*
|
|
187
|
+
* A stale index answers text queries from terms an older analysis wrote, and
|
|
188
|
+
* every such result reports `analysisStale`. Rebuilding fixes it, and this
|
|
189
|
+
* setting controls whether the engine starts that work itself.
|
|
190
|
+
*
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
193
|
+
interface AnalysisConfig {
|
|
194
|
+
/** `auto` rebuilds a stale index in the background, and `manual` leaves it to you. The engine rebuilds automatically by default. */
|
|
195
|
+
rebuild?: 'auto' | 'manual';
|
|
196
|
+
/**
|
|
197
|
+
* Called once for each stale index the engine finds.
|
|
198
|
+
*
|
|
199
|
+
* @param index - The index that is stale, and how far behind it is.
|
|
200
|
+
* @param rebuild - Starts the rebuild and resolves once every partition
|
|
201
|
+
* carries current terms. Under `manual` nothing rebuilds until you call it.
|
|
202
|
+
*/
|
|
203
|
+
onStaleAnalysis?(index: StaleAnalysis, rebuild: () => Promise<void>): void | Promise<void>;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Write-ahead logging and checkpointing, which recover the writes made since
|
|
207
|
+
* the last snapshot.
|
|
208
|
+
*
|
|
209
|
+
* The `wal` tier logs every mutation before applying it, so a crash costs
|
|
210
|
+
* nothing once the log replays. The `snapshot` tier writes whole partitions on
|
|
211
|
+
* an interval, which is cheaper to run and loses whatever arrived after the
|
|
212
|
+
* last write.
|
|
213
|
+
*
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
216
|
+
interface DurabilityConfig {
|
|
217
|
+
/** `wal` logs every mutation, and `snapshot` writes whole partitions on an interval. */
|
|
218
|
+
tier?: 'wal' | 'snapshot';
|
|
219
|
+
/** The engine writes the log and its checkpoints into this directory. */
|
|
220
|
+
directory?: string;
|
|
221
|
+
/** `sync` flushes before a write resolves, and `async` flushes on the interval below. */
|
|
222
|
+
mode?: 'sync' | 'async';
|
|
223
|
+
/** In `async` mode the engine flushes this many milliseconds apart. */
|
|
224
|
+
flushIntervalMs?: number;
|
|
225
|
+
/** The log rolls over to a new segment once it reaches this size. */
|
|
226
|
+
segmentMaxBytes?: number;
|
|
227
|
+
/** The engine checkpoints this many milliseconds apart, which shortens the replay a restart has to do. */
|
|
228
|
+
checkpointIntervalMs?: number;
|
|
229
|
+
/** This many mutations trigger a checkpoint before the interval elapses. */
|
|
230
|
+
checkpointMutationThreshold?: number;
|
|
231
|
+
/** Compaction reclaims the log once this fraction of it is dead. */
|
|
232
|
+
compactionThreshold?: number;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* When the engine moves its indexes onto worker threads, and how many it uses.
|
|
236
|
+
*
|
|
237
|
+
* An engine starts on the main thread, where a small index answers fastest.
|
|
238
|
+
* Once an index passes a threshold the engine promotes it to a worker pool, so
|
|
239
|
+
* that indexing and searching run off the calling thread.
|
|
240
|
+
*
|
|
241
|
+
* @public
|
|
242
|
+
*/
|
|
243
|
+
interface WorkerConfig {
|
|
244
|
+
/** Setting this allows promotion to worker threads. The engine promotes nothing while it is false. */
|
|
245
|
+
enabled?: boolean;
|
|
246
|
+
/** The pool runs this many workers. The engine derives a count from the host's cores by default. */
|
|
247
|
+
count?: number;
|
|
248
|
+
/** This many documents in one index trigger promotion. */
|
|
249
|
+
promotionThreshold?: number;
|
|
250
|
+
/** This many documents across every index trigger promotion. */
|
|
251
|
+
totalPromotionThreshold?: number;
|
|
252
|
+
/** Each worker imports this module on start-up, which is how a worker reaches a custom tokeniser or language. */
|
|
253
|
+
bootstrapModule?: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export type { AnalysisConfig as A, DurabilityConfig as D, IndexContext as I, NarsilConfig as N, PartitionContext as P, RemoveContext as R, SearchContext as S, UpdateContext as U, WorkerConfig as W, InsertContext as a, NarsilPlugin as b, StaleAnalysis as c, WorkerContext as d };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { createDirectExecutor } from './chunk-
|
|
1
|
+
export { createDirectExecutor } from './chunk-ASI6AOW2.mjs';
|
|
2
2
|
import './chunk-TGP5M5R7.mjs';
|
|
3
3
|
import './chunk-S7RJJMHI.mjs';
|
|
4
4
|
import './chunk-U2BKYEC7.mjs';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-UNJZ7ZDB.mjs';
|
|
@@ -1,16 +1,57 @@
|
|
|
1
|
-
import { C as ClusterCoordinator } from '../../types-
|
|
2
|
-
import '../../schema-
|
|
3
|
-
import '../../adapters-
|
|
1
|
+
import { C as ClusterCoordinator } from '../../types-BV3nAKTL.js';
|
|
2
|
+
import '../../schema-CE6S_aAr.js';
|
|
3
|
+
import '../../adapters-CVqI5NBt.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* How {@link createEtcdCoordinator} reaches etcd, and how long the leases it
|
|
7
|
+
* takes there survive.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
5
11
|
interface EtcdCoordinatorConfig {
|
|
12
|
+
/** The coordinator connects to these etcd endpoints. */
|
|
6
13
|
endpoints: string[];
|
|
14
|
+
/** The coordinator writes every key under this prefix, which lets one etcd cluster hold several Narsil clusters. */
|
|
7
15
|
keyPrefix: string;
|
|
16
|
+
/** A node's registration survives this many seconds without a heartbeat, after which peers treat the node as gone. */
|
|
8
17
|
nodeHeartbeatTtlSeconds: number;
|
|
18
|
+
/** The controller lease survives this many seconds without renewal, which is how long a failover takes at worst. */
|
|
9
19
|
leaseTtlSeconds: number;
|
|
10
20
|
}
|
|
11
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Checks that a node id is safe to use as part of an etcd key.
|
|
24
|
+
*
|
|
25
|
+
* The coordinator builds each key from the node id, so an id carrying a
|
|
26
|
+
* separator or a traversal sequence would reach another node's keys. Call it
|
|
27
|
+
* when you generate ids yourself, and the coordinator calls it on every
|
|
28
|
+
* registration regardless.
|
|
29
|
+
*
|
|
30
|
+
* @param nodeId - The id to check.
|
|
31
|
+
* @throws A `NarsilError` with `CONFIG_INVALID` when the id is empty, longer
|
|
32
|
+
* than 255 characters, or carries a slash, a backslash, `..`, or a null byte.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
12
36
|
declare function validateNodeId(nodeId: string): void;
|
|
13
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Builds a coordinator backed by etcd, which is what holds a cluster's shared
|
|
40
|
+
* state across hosts and restarts.
|
|
41
|
+
*
|
|
42
|
+
* etcd gives the coordinator what a cluster depends on: leases that expire once
|
|
43
|
+
* a node misses its heartbeats, and compare-and-set writes that keep two
|
|
44
|
+
* controllers from disagreeing. Install `etcd3` alongside this package,
|
|
45
|
+
* because it is an optional peer dependency this call loads on demand.
|
|
46
|
+
*
|
|
47
|
+
* @param config - Endpoints, key prefix, and lease lifetimes to override.
|
|
48
|
+
* Anything you leave out keeps its default.
|
|
49
|
+
* @returns A coordinator you pass as a cluster node's `coordinator`.
|
|
50
|
+
* @throws A `NarsilError` with `COORDINATOR_DEPENDENCY_MISSING` when `etcd3`
|
|
51
|
+
* is not installed.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
14
55
|
declare function createEtcdCoordinator(config?: Partial<EtcdCoordinatorConfig>): Promise<ClusterCoordinator>;
|
|
15
56
|
|
|
16
57
|
export { type EtcdCoordinatorConfig, createEtcdCoordinator, validateNodeId };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createEtcdCoordinator, validateNodeId } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { createEtcdCoordinator, validateNodeId } from '../../chunk-FKK76OR7.mjs';
|
|
2
|
+
import '../../chunk-UNJZ7ZDB.mjs';
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { C as ClusterCoordinator } from '../../types-
|
|
2
|
-
import '../../schema-
|
|
3
|
-
import '../../adapters-
|
|
1
|
+
import { C as ClusterCoordinator } from '../../types-BV3nAKTL.js';
|
|
2
|
+
import '../../schema-CE6S_aAr.js';
|
|
3
|
+
import '../../adapters-CVqI5NBt.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Builds a coordinator that holds the cluster's shared state in one process's
|
|
7
|
+
* memory, which is what runs a whole cluster inside a test.
|
|
8
|
+
*
|
|
9
|
+
* Every node has to share the same instance, and nothing survives the process,
|
|
10
|
+
* so use {@link createEtcdCoordinator} for a cluster that spans hosts.
|
|
11
|
+
*
|
|
12
|
+
* @returns A coordinator you pass as a cluster node's `coordinator`.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
5
16
|
declare function createInMemoryCoordinator(): ClusterCoordinator;
|
|
6
17
|
|
|
7
18
|
export { createInMemoryCoordinator };
|