@delali/narsil 0.3.1-next.152 → 0.3.1-next.153
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.
|
@@ -63,6 +63,15 @@ interface EtcdCoordinatorConfig {
|
|
|
63
63
|
* address alone, so that the password never crosses a network in clear text.
|
|
64
64
|
*/
|
|
65
65
|
auth?: EtcdAuthConfig;
|
|
66
|
+
/**
|
|
67
|
+
* The coordinator calls this with every error that a watch handler throws,
|
|
68
|
+
* including one raised by a value under a watched prefix that the
|
|
69
|
+
* coordinator cannot read. The coordinator then skips that change, reopens
|
|
70
|
+
* the watch, and lists the prefix again, so that the error never ends the
|
|
71
|
+
* process and every later change still arrives. The coordinator drops
|
|
72
|
+
* these errors when you leave this out.
|
|
73
|
+
*/
|
|
74
|
+
onWatchError?: (error: Error) => void;
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
/**
|
|
@@ -227,44 +227,202 @@ async function loadEtcd3Module() {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
// src/distribution/coordinator/etcd/
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
230
|
+
// src/distribution/coordinator/etcd/watch-stream.ts
|
|
231
|
+
var WatchAttachError = class extends NarsilError {
|
|
232
|
+
};
|
|
233
|
+
function shutDownError() {
|
|
234
|
+
return new NarsilError(ErrorCodes.CONFIG_INVALID, "Coordinator has been shut down");
|
|
235
|
+
}
|
|
236
|
+
function attachFailure(message) {
|
|
237
|
+
return new WatchAttachError(ErrorCodes.COORDINATOR_UNAVAILABLE, message);
|
|
238
|
+
}
|
|
239
|
+
function prefixRangeEnd(prefix) {
|
|
240
|
+
for (let position = prefix.length - 1; position >= 0; position--) {
|
|
241
|
+
const byte = prefix[position];
|
|
242
|
+
if (byte !== void 0 && byte < 255) {
|
|
243
|
+
const end = Buffer.from(prefix.subarray(0, position + 1));
|
|
244
|
+
end[position] = byte + 1;
|
|
245
|
+
return end;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return Buffer.from([0]);
|
|
249
|
+
}
|
|
250
|
+
async function openOne(client, prefix, startRevision, listener, registry) {
|
|
251
|
+
const stream = await client.watchClient.watch();
|
|
252
|
+
let attached = false;
|
|
253
|
+
let closing = false;
|
|
254
|
+
let finished = false;
|
|
255
|
+
let settleAttach = () => {
|
|
256
|
+
};
|
|
257
|
+
let markFinished = () => {
|
|
258
|
+
};
|
|
259
|
+
const done = new Promise((resolve) => {
|
|
260
|
+
markFinished = resolve;
|
|
261
|
+
});
|
|
262
|
+
const attachedOrFailed = new Promise((resolve) => {
|
|
263
|
+
settleAttach = resolve;
|
|
264
|
+
});
|
|
265
|
+
const watch = {
|
|
266
|
+
close() {
|
|
267
|
+
if (!closing) {
|
|
268
|
+
closing = true;
|
|
269
|
+
try {
|
|
270
|
+
stream.end();
|
|
271
|
+
stream.cancel();
|
|
272
|
+
} catch (_) {
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return done;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
function finish() {
|
|
279
|
+
if (finished) return;
|
|
280
|
+
finished = true;
|
|
281
|
+
registry.forget(watch);
|
|
282
|
+
markFinished();
|
|
283
|
+
if (!attached) settleAttach(attachFailure("the etcd watch stream ended before etcd attached the watch"));
|
|
284
|
+
else if (!closing) listener.lost();
|
|
285
|
+
}
|
|
286
|
+
function receive(response) {
|
|
287
|
+
if (closing || finished) return;
|
|
288
|
+
if (!attached) {
|
|
289
|
+
if (!response.created) return;
|
|
290
|
+
if (response.canceled) {
|
|
291
|
+
settleAttach(attachFailure(`etcd refused the watch: ${response.cancel_reason || "no reason given"}`));
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
attached = true;
|
|
295
|
+
settleAttach(null);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
for (const event of response.events ?? []) {
|
|
299
|
+
try {
|
|
300
|
+
if (event.type === "Put") listener.put(event.kv);
|
|
301
|
+
else if (event.type === "Delete") listener.delete(event.kv);
|
|
302
|
+
} catch (handlerError) {
|
|
303
|
+
void watch.close();
|
|
304
|
+
listener.handlerFailed(handlerError);
|
|
305
|
+
listener.lost();
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (response.canceled) {
|
|
310
|
+
void watch.close();
|
|
311
|
+
listener.lost();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
stream.on("data", (response) => {
|
|
315
|
+
try {
|
|
316
|
+
receive(response);
|
|
317
|
+
} catch (_) {
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
stream.on("error", () => {
|
|
321
|
+
});
|
|
322
|
+
stream.on("status", () => {
|
|
323
|
+
try {
|
|
324
|
+
finish();
|
|
325
|
+
} catch (_) {
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
registry.remember(watch);
|
|
329
|
+
if (registry.isClosed()) {
|
|
330
|
+
await watch.close();
|
|
331
|
+
throw shutDownError();
|
|
332
|
+
}
|
|
333
|
+
const timer = setTimeout(
|
|
334
|
+
() => settleAttach(attachFailure(`etcd did not attach the watch within ${ETCD_WATCH_ATTACH_TIMEOUT_MS} ms`)),
|
|
335
|
+
ETCD_WATCH_ATTACH_TIMEOUT_MS
|
|
336
|
+
);
|
|
337
|
+
timer.unref?.();
|
|
338
|
+
const key = Buffer.from(prefix);
|
|
339
|
+
try {
|
|
340
|
+
stream.write({ create_request: { key, range_end: prefixRangeEnd(key), start_revision: startRevision } });
|
|
341
|
+
} catch (_) {
|
|
342
|
+
settleAttach(attachFailure("the etcd watch stream refused the watch request"));
|
|
343
|
+
}
|
|
344
|
+
const failure = await attachedOrFailed;
|
|
345
|
+
clearTimeout(timer);
|
|
346
|
+
if (failure !== null) {
|
|
347
|
+
await watch.close();
|
|
348
|
+
throw registry.isClosed() ? shutDownError() : failure;
|
|
349
|
+
}
|
|
350
|
+
return watch;
|
|
351
|
+
}
|
|
352
|
+
function createWatchStreams() {
|
|
353
|
+
const open = /* @__PURE__ */ new Set();
|
|
354
|
+
const pending = /* @__PURE__ */ new Set();
|
|
355
|
+
let opening = 0;
|
|
356
|
+
let closed = false;
|
|
357
|
+
function track(operation) {
|
|
358
|
+
const followed = operation.then(
|
|
359
|
+
() => {
|
|
360
|
+
},
|
|
361
|
+
() => {
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
pending.add(followed);
|
|
365
|
+
void followed.then(() => pending.delete(followed));
|
|
366
|
+
return operation;
|
|
367
|
+
}
|
|
368
|
+
async function openTracked(client, prefix, startRevision, listener) {
|
|
369
|
+
if (closed) throw shutDownError();
|
|
370
|
+
if (open.size + opening >= MAX_WATCHERS) {
|
|
371
|
+
throw new NarsilError(ErrorCodes.CONFIG_INVALID, `Maximum watcher limit (${MAX_WATCHERS}) reached`, {
|
|
372
|
+
currentCount: open.size + opening
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
opening += 1;
|
|
376
|
+
let reserved = true;
|
|
377
|
+
const releaseReservation = () => {
|
|
378
|
+
if (!reserved) return;
|
|
379
|
+
reserved = false;
|
|
380
|
+
opening -= 1;
|
|
246
381
|
};
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
382
|
+
const registry = {
|
|
383
|
+
remember(watch) {
|
|
384
|
+
releaseReservation();
|
|
385
|
+
open.add(watch);
|
|
386
|
+
},
|
|
387
|
+
forget: (watch) => open.delete(watch),
|
|
388
|
+
isClosed: () => closed
|
|
250
389
|
};
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
watcher.off("error", onDropped);
|
|
390
|
+
try {
|
|
391
|
+
return await openOne(client, prefix, startRevision, listener, registry);
|
|
392
|
+
} finally {
|
|
393
|
+
releaseReservation();
|
|
256
394
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
open: (client, prefix, startRevision, listener) => track(openTracked(client, prefix, startRevision, listener)),
|
|
398
|
+
track,
|
|
399
|
+
isClosed: () => closed,
|
|
400
|
+
async closeAll() {
|
|
401
|
+
closed = true;
|
|
402
|
+
while (open.size > 0 || pending.size > 0) {
|
|
403
|
+
await Promise.all([...[...open].map((watch) => watch.close()), ...pending]);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/distribution/coordinator/etcd/prefix-watch.ts
|
|
410
|
+
function blamesTheConnection(error) {
|
|
411
|
+
return error instanceof WatchAttachError || !(error instanceof NarsilError);
|
|
261
412
|
}
|
|
262
|
-
|
|
413
|
+
function watchPrefix(context, prefix, handlers) {
|
|
414
|
+
const { streams } = context;
|
|
415
|
+
if (streams.isClosed()) {
|
|
416
|
+
return Promise.reject(new NarsilError(ErrorCodes.CONFIG_INVALID, "Coordinator has been shut down"));
|
|
417
|
+
}
|
|
263
418
|
const modRevisionByKey = /* @__PURE__ */ new Map();
|
|
264
419
|
let current = null;
|
|
265
420
|
let stopped = false;
|
|
266
421
|
let reopenTimer = null;
|
|
267
422
|
let reopenDelayMs = RECONNECT_FIRST_DELAY_MS;
|
|
423
|
+
function inactive() {
|
|
424
|
+
return stopped || streams.isClosed();
|
|
425
|
+
}
|
|
268
426
|
function recordPut(kv) {
|
|
269
427
|
modRevisionByKey.set(kv.key.toString(), kv.mod_revision);
|
|
270
428
|
handlers.put(kv);
|
|
@@ -273,6 +431,13 @@ async function watchPrefix(context, prefix, handlers) {
|
|
|
273
431
|
modRevisionByKey.delete(fullKey);
|
|
274
432
|
handlers.delete(fullKey);
|
|
275
433
|
}
|
|
434
|
+
function reportingHandlerErrors(record) {
|
|
435
|
+
try {
|
|
436
|
+
record();
|
|
437
|
+
} catch (error) {
|
|
438
|
+
context.reportHandlerError(error);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
276
441
|
async function listMissedChanges(reportMissedChanges) {
|
|
277
442
|
const listing = await context.client.getAll().prefix(prefix).exec();
|
|
278
443
|
const listedKeys = /* @__PURE__ */ new Set();
|
|
@@ -282,51 +447,54 @@ async function watchPrefix(context, prefix, handlers) {
|
|
|
282
447
|
if (!reportMissedChanges) {
|
|
283
448
|
modRevisionByKey.set(fullKey, kv.mod_revision);
|
|
284
449
|
} else if (modRevisionByKey.get(fullKey) !== kv.mod_revision) {
|
|
285
|
-
recordPut(kv);
|
|
450
|
+
reportingHandlerErrors(() => recordPut(kv));
|
|
286
451
|
}
|
|
287
452
|
}
|
|
288
453
|
if (reportMissedChanges) {
|
|
289
454
|
for (const fullKey of [...modRevisionByKey.keys()]) {
|
|
290
|
-
if (!listedKeys.has(fullKey)) recordDelete(fullKey);
|
|
455
|
+
if (!listedKeys.has(fullKey)) reportingHandlerErrors(() => recordDelete(fullKey));
|
|
291
456
|
}
|
|
292
457
|
}
|
|
293
458
|
return String(BigInt(listing.header.revision) + 1n);
|
|
294
459
|
}
|
|
295
|
-
async function watchFrom(
|
|
460
|
+
async function watchFrom(startRevision) {
|
|
296
461
|
const client = context.watchClient.current();
|
|
297
|
-
|
|
462
|
+
let opened = null;
|
|
463
|
+
let lostWhileOpening = false;
|
|
464
|
+
let watch;
|
|
298
465
|
try {
|
|
299
|
-
await
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
466
|
+
watch = await streams.open(client, prefix, startRevision, {
|
|
467
|
+
put: recordPut,
|
|
468
|
+
delete: (kv) => recordDelete(kv.key.toString()),
|
|
469
|
+
handlerFailed: context.reportHandlerError,
|
|
470
|
+
lost() {
|
|
471
|
+
if (opened === null) lostWhileOpening = true;
|
|
472
|
+
else reopenAfterFailure(opened);
|
|
473
|
+
}
|
|
304
474
|
});
|
|
305
|
-
|
|
475
|
+
} catch (error) {
|
|
476
|
+
if (!streams.isClosed() && blamesTheConnection(error)) context.watchClient.replace(client);
|
|
306
477
|
throw error;
|
|
307
478
|
}
|
|
308
|
-
if (
|
|
309
|
-
|
|
310
|
-
});
|
|
479
|
+
if (inactive()) {
|
|
480
|
+
await watch.close();
|
|
311
481
|
return;
|
|
312
482
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
watcher.on("disconnected", () => reopenAfterFailure(watcher));
|
|
317
|
-
context.addWatcher(watcher);
|
|
318
|
-
current = watcher;
|
|
483
|
+
opened = watch;
|
|
484
|
+
current = watch;
|
|
485
|
+
if (lostWhileOpening) reopenAfterFailure(watch);
|
|
319
486
|
}
|
|
320
487
|
async function listThenWatch(reportMissedChanges) {
|
|
321
488
|
await watchFrom(await listMissedChanges(reportMissedChanges));
|
|
322
489
|
}
|
|
323
490
|
function scheduleReopen() {
|
|
324
|
-
if (
|
|
491
|
+
if (inactive()) return;
|
|
325
492
|
const delayMs = reopenDelayMs;
|
|
326
493
|
reopenDelayMs = Math.min(reopenDelayMs * 2, RECONNECT_LONGEST_DELAY_MS);
|
|
327
494
|
reopenTimer = setTimeout(() => {
|
|
328
495
|
reopenTimer = null;
|
|
329
|
-
|
|
496
|
+
if (inactive()) return;
|
|
497
|
+
streams.track(listThenWatch(true)).then(
|
|
330
498
|
() => {
|
|
331
499
|
reopenDelayMs = RECONNECT_FIRST_DELAY_MS;
|
|
332
500
|
},
|
|
@@ -338,26 +506,29 @@ async function watchPrefix(context, prefix, handlers) {
|
|
|
338
506
|
function reopenAfterFailure(failed) {
|
|
339
507
|
if (current !== failed) return;
|
|
340
508
|
current = null;
|
|
341
|
-
|
|
509
|
+
void failed.close();
|
|
342
510
|
scheduleReopen();
|
|
343
511
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
return () => {
|
|
351
|
-
stopped = true;
|
|
352
|
-
if (reopenTimer !== null) {
|
|
353
|
-
clearTimeout(reopenTimer);
|
|
354
|
-
reopenTimer = null;
|
|
355
|
-
}
|
|
356
|
-
if (current !== null) {
|
|
357
|
-
context.removeWatcher(current);
|
|
358
|
-
current = null;
|
|
512
|
+
async function start() {
|
|
513
|
+
const startRevision = await listMissedChanges(false);
|
|
514
|
+
try {
|
|
515
|
+
await watchFrom(startRevision);
|
|
516
|
+
} catch (_) {
|
|
517
|
+
scheduleReopen();
|
|
359
518
|
}
|
|
360
|
-
|
|
519
|
+
return () => {
|
|
520
|
+
stopped = true;
|
|
521
|
+
if (reopenTimer !== null) {
|
|
522
|
+
clearTimeout(reopenTimer);
|
|
523
|
+
reopenTimer = null;
|
|
524
|
+
}
|
|
525
|
+
if (current !== null) {
|
|
526
|
+
void current.close();
|
|
527
|
+
current = null;
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
return streams.track(start());
|
|
361
532
|
}
|
|
362
533
|
function serializeAllocationTable(table) {
|
|
363
534
|
const serializable = {
|
|
@@ -584,6 +755,17 @@ function createEtcdWriteGuard(etcd3, maxRequestBytes) {
|
|
|
584
755
|
};
|
|
585
756
|
}
|
|
586
757
|
|
|
758
|
+
// src/distribution/coordinator/etcd/require-leader.ts
|
|
759
|
+
var ETCD_WATCH_METHOD_PATH = "/etcdserverpb.Watch/Watch";
|
|
760
|
+
var ETCD_REQUIRE_LEADER_METADATA_KEY = "hasleader";
|
|
761
|
+
var ETCD_REQUIRE_LEADER_METADATA_VALUE = "true";
|
|
762
|
+
function requireLeaderOnWatchStreams(properties) {
|
|
763
|
+
if (properties.methodDefinition.path !== ETCD_WATCH_METHOD_PATH) return properties;
|
|
764
|
+
const metadata = properties.metadata.clone();
|
|
765
|
+
metadata.set(ETCD_REQUIRE_LEADER_METADATA_KEY, ETCD_REQUIRE_LEADER_METADATA_VALUE);
|
|
766
|
+
return { ...properties, metadata };
|
|
767
|
+
}
|
|
768
|
+
|
|
587
769
|
// src/distribution/coordinator/etcd/security.ts
|
|
588
770
|
var SECURE_SCHEME = "https://";
|
|
589
771
|
var LOOPBACK_IPV4 = /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
@@ -751,11 +933,8 @@ function storedValueMethods(context) {
|
|
|
751
933
|
const prefix = keys.schemaPrefix();
|
|
752
934
|
return watchPrefix2(prefix, {
|
|
753
935
|
put(kv) {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
handler({ type: "schema_created", indexName: extractSuffix(kv.key.toString(), prefix), schema });
|
|
757
|
-
} catch (_) {
|
|
758
|
-
}
|
|
936
|
+
const schema = deserializeSchema(kv.value);
|
|
937
|
+
handler({ type: "schema_created", indexName: extractSuffix(kv.key.toString(), prefix), schema });
|
|
759
938
|
},
|
|
760
939
|
delete(fullKey) {
|
|
761
940
|
handler({ type: "schema_dropped", indexName: extractSuffix(fullKey, prefix), schema: null });
|
|
@@ -845,7 +1024,8 @@ async function createEtcdCoordinator(config) {
|
|
|
845
1024
|
grpcOptions: {
|
|
846
1025
|
"grpc.max_receive_message_length": ETCD_MAX_RESPONSE_BYTES,
|
|
847
1026
|
"grpc.keepalive_time_ms": ETCD_KEEPALIVE_TIME_MS,
|
|
848
|
-
"grpc.keepalive_timeout_ms": ETCD_KEEPALIVE_TIMEOUT_MS
|
|
1027
|
+
"grpc.keepalive_timeout_ms": ETCD_KEEPALIVE_TIMEOUT_MS,
|
|
1028
|
+
callInvocationTransformer: requireLeaderOnWatchStreams
|
|
849
1029
|
},
|
|
850
1030
|
defaultCallOptions: (context) => context.isStream ? {} : { deadline: Date.now() + ETCD_CALL_TIMEOUT_MS },
|
|
851
1031
|
faultHandling: { host: (endpoint) => createEndpointBreaker(endpoint, etcd3Module.isRecoverableError) },
|
|
@@ -861,30 +1041,23 @@ async function createEtcdCoordinator(config) {
|
|
|
861
1041
|
}
|
|
862
1042
|
const guard = createEtcdWriteGuard(etcd3Module, resolvedConfig.maxRequestBytes);
|
|
863
1043
|
const leaseManager = new LeaseManager();
|
|
864
|
-
const watchers = /* @__PURE__ */ new Set();
|
|
865
1044
|
let isShutdown = false;
|
|
866
1045
|
function assertNotShutdown() {
|
|
867
1046
|
if (isShutdown) {
|
|
868
1047
|
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "Coordinator has been shut down");
|
|
869
1048
|
}
|
|
870
1049
|
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
1050
|
+
const watchClient = createReplaceableWatchClient(openClient);
|
|
1051
|
+
const streams = createWatchStreams();
|
|
1052
|
+
const { onWatchError } = resolvedConfig;
|
|
1053
|
+
function reportHandlerError(error) {
|
|
1054
|
+
if (onWatchError === void 0) return;
|
|
1055
|
+
try {
|
|
1056
|
+
onWatchError(error instanceof Error ? error : new Error(String(error)));
|
|
1057
|
+
} catch (_) {
|
|
878
1058
|
}
|
|
879
|
-
watchers.add(watcher);
|
|
880
|
-
}
|
|
881
|
-
function removeWatcher(watcher) {
|
|
882
|
-
watcher.cancel().catch(() => {
|
|
883
|
-
});
|
|
884
|
-
watchers.delete(watcher);
|
|
885
1059
|
}
|
|
886
|
-
const
|
|
887
|
-
const watchContext = { client, watchClient, addWatcher, removeWatcher, isShutdown: () => isShutdown };
|
|
1060
|
+
const watchContext = { client, watchClient, streams, reportHandlerError };
|
|
888
1061
|
const coordinator = {
|
|
889
1062
|
async registerNode(registration) {
|
|
890
1063
|
assertNotShutdown();
|
|
@@ -947,11 +1120,8 @@ async function createEtcdCoordinator(config) {
|
|
|
947
1120
|
const prefix = keys.nodePrefix();
|
|
948
1121
|
return watchPrefix(watchContext, prefix, {
|
|
949
1122
|
put(kv) {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
handler({ type: "node_joined", nodeId: registration.nodeId, registration });
|
|
953
|
-
} catch (_) {
|
|
954
|
-
}
|
|
1123
|
+
const registration = deserializeNodeRegistration(kv.value);
|
|
1124
|
+
handler({ type: "node_joined", nodeId: registration.nodeId, registration });
|
|
955
1125
|
},
|
|
956
1126
|
delete(fullKey) {
|
|
957
1127
|
handler({ type: "node_left", nodeId: extractSuffix(fullKey, prefix), registration: null });
|
|
@@ -1008,11 +1178,8 @@ async function createEtcdCoordinator(config) {
|
|
|
1008
1178
|
assertNotShutdown();
|
|
1009
1179
|
return watchPrefix(watchContext, keys.allocationPrefix(), {
|
|
1010
1180
|
put(kv) {
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
handler({ indexName: table.indexName, table });
|
|
1014
|
-
} catch (_) {
|
|
1015
|
-
}
|
|
1181
|
+
const table = deserializeAllocationTable(kv.value);
|
|
1182
|
+
handler({ indexName: table.indexName, table });
|
|
1016
1183
|
},
|
|
1017
1184
|
delete() {
|
|
1018
1185
|
}
|
|
@@ -1100,13 +1267,7 @@ async function createEtcdCoordinator(config) {
|
|
|
1100
1267
|
return;
|
|
1101
1268
|
}
|
|
1102
1269
|
isShutdown = true;
|
|
1103
|
-
|
|
1104
|
-
for (const watcher of watchers) {
|
|
1105
|
-
cancelPromises.push(watcher.cancel().catch(() => {
|
|
1106
|
-
}));
|
|
1107
|
-
}
|
|
1108
|
-
await Promise.all(cancelPromises);
|
|
1109
|
-
watchers.clear();
|
|
1270
|
+
await streams.closeAll();
|
|
1110
1271
|
await leaseManager.revokeAll();
|
|
1111
1272
|
watchClient.close();
|
|
1112
1273
|
client.close();
|
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.153",
|
|
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)",
|
|
@@ -383,11 +383,11 @@
|
|
|
383
383
|
}
|
|
384
384
|
},
|
|
385
385
|
"optionalDependencies": {
|
|
386
|
-
"@delali/narsil-native-darwin-arm64": "0.3.1-next.
|
|
387
|
-
"@delali/narsil-native-darwin-x64": "0.3.1-next.
|
|
388
|
-
"@delali/narsil-native-linux-arm64": "0.3.1-next.
|
|
389
|
-
"@delali/narsil-native-linux-x64": "0.3.1-next.
|
|
390
|
-
"@delali/narsil-native-win32-arm64": "0.3.1-next.
|
|
391
|
-
"@delali/narsil-native-win32-x64": "0.3.1-next.
|
|
386
|
+
"@delali/narsil-native-darwin-arm64": "0.3.1-next.153",
|
|
387
|
+
"@delali/narsil-native-darwin-x64": "0.3.1-next.153",
|
|
388
|
+
"@delali/narsil-native-linux-arm64": "0.3.1-next.153",
|
|
389
|
+
"@delali/narsil-native-linux-x64": "0.3.1-next.153",
|
|
390
|
+
"@delali/narsil-native-win32-arm64": "0.3.1-next.153",
|
|
391
|
+
"@delali/narsil-native-win32-x64": "0.3.1-next.153"
|
|
392
392
|
}
|
|
393
393
|
}
|