@luvio/environments 0.57.0 → 0.59.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.
|
@@ -425,7 +425,8 @@ function copy(source) {
|
|
|
425
425
|
return { ...source };
|
|
426
426
|
}
|
|
427
427
|
function flushStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler) {
|
|
428
|
-
const durableRecords = create(
|
|
428
|
+
const durableRecords = create(null);
|
|
429
|
+
const evictedRecords = create(null);
|
|
429
430
|
const { records, metadata: storeMetadata, visitedIds, refreshedIds } = store;
|
|
430
431
|
// TODO: W-8909393 Once metadata is stored in its own segment we need to
|
|
431
432
|
// call setEntries for the visitedIds on default segment and call setEntries
|
|
@@ -434,8 +435,9 @@ function flushStoreValuesToDurableStore(store, durableStore, durableStoreErrorHa
|
|
|
434
435
|
for (let i = 0, len = keys$1.length; i < len; i += 1) {
|
|
435
436
|
const key = keys$1[i];
|
|
436
437
|
const record = records[key];
|
|
437
|
-
// this record has been evicted,
|
|
438
|
+
// this record has been evicted, evict from DS
|
|
438
439
|
if (record === undefined) {
|
|
440
|
+
evictedRecords[key] = true;
|
|
439
441
|
continue;
|
|
440
442
|
}
|
|
441
443
|
const metadata = storeMetadata[key];
|
|
@@ -448,11 +450,27 @@ function flushStoreValuesToDurableStore(store, durableStore, durableStoreErrorHa
|
|
|
448
450
|
durableRecords[key].metadata = copy(metadata);
|
|
449
451
|
}
|
|
450
452
|
}
|
|
453
|
+
const durableStoreOperations = [];
|
|
454
|
+
// publishes
|
|
451
455
|
const recordKeys = keys(durableRecords);
|
|
452
456
|
if (recordKeys.length > 0) {
|
|
453
|
-
|
|
454
|
-
.
|
|
455
|
-
|
|
457
|
+
durableStoreOperations.push({
|
|
458
|
+
type: DurableStoreOperationType.SetEntries,
|
|
459
|
+
entries: durableRecords,
|
|
460
|
+
segment: DefaultDurableSegment,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
// evicts
|
|
464
|
+
const evictedKeys = keys(evictedRecords);
|
|
465
|
+
if (evictedKeys.length > 0) {
|
|
466
|
+
durableStoreOperations.push({
|
|
467
|
+
type: DurableStoreOperationType.EvictEntries,
|
|
468
|
+
ids: evictedKeys,
|
|
469
|
+
segment: DefaultDurableSegment,
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
if (durableStoreOperations.length > 0) {
|
|
473
|
+
return durableStore.batchOperations(durableStoreOperations).catch(durableStoreErrorHandler);
|
|
456
474
|
}
|
|
457
475
|
return Promise.resolve();
|
|
458
476
|
}
|
|
@@ -631,13 +649,10 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
631
649
|
};
|
|
632
650
|
const storeEvict = function (key) {
|
|
633
651
|
validateNotDisposed();
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
ingestStagingStore.evict(key);
|
|
652
|
+
if (ingestStagingStore === null) {
|
|
653
|
+
ingestStagingStore = new Store();
|
|
637
654
|
}
|
|
638
|
-
|
|
639
|
-
// do not await
|
|
640
|
-
durableStore.evictEntries([key], DefaultDurableSegment).catch(durableStoreErrorHandler);
|
|
655
|
+
ingestStagingStore.evict(key);
|
|
641
656
|
};
|
|
642
657
|
const getNode = function (key) {
|
|
643
658
|
validateNotDisposed();
|
|
@@ -749,7 +764,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
749
764
|
return buildStaleWhileRevalidateImplementation({
|
|
750
765
|
validateNotDisposed,
|
|
751
766
|
reviveSnapshotWithCachePolicy,
|
|
752
|
-
}, cachePolicy.
|
|
767
|
+
}, cachePolicy.staleDurationSeconds);
|
|
753
768
|
default: {
|
|
754
769
|
if (process.env.NODE_ENV !== 'production') {
|
|
755
770
|
throw new Error(`unrecognized cache policy: ${JSON.stringify(cachePolicy)}`);
|
|
@@ -428,7 +428,8 @@
|
|
|
428
428
|
return { ...source };
|
|
429
429
|
}
|
|
430
430
|
function flushStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler) {
|
|
431
|
-
const durableRecords = create(
|
|
431
|
+
const durableRecords = create(null);
|
|
432
|
+
const evictedRecords = create(null);
|
|
432
433
|
const { records, metadata: storeMetadata, visitedIds, refreshedIds } = store;
|
|
433
434
|
// TODO: W-8909393 Once metadata is stored in its own segment we need to
|
|
434
435
|
// call setEntries for the visitedIds on default segment and call setEntries
|
|
@@ -437,8 +438,9 @@
|
|
|
437
438
|
for (let i = 0, len = keys$1.length; i < len; i += 1) {
|
|
438
439
|
const key = keys$1[i];
|
|
439
440
|
const record = records[key];
|
|
440
|
-
// this record has been evicted,
|
|
441
|
+
// this record has been evicted, evict from DS
|
|
441
442
|
if (record === undefined) {
|
|
443
|
+
evictedRecords[key] = true;
|
|
442
444
|
continue;
|
|
443
445
|
}
|
|
444
446
|
const metadata = storeMetadata[key];
|
|
@@ -451,11 +453,27 @@
|
|
|
451
453
|
durableRecords[key].metadata = copy(metadata);
|
|
452
454
|
}
|
|
453
455
|
}
|
|
456
|
+
const durableStoreOperations = [];
|
|
457
|
+
// publishes
|
|
454
458
|
const recordKeys = keys(durableRecords);
|
|
455
459
|
if (recordKeys.length > 0) {
|
|
456
|
-
|
|
457
|
-
.
|
|
458
|
-
|
|
460
|
+
durableStoreOperations.push({
|
|
461
|
+
type: exports.DurableStoreOperationType.SetEntries,
|
|
462
|
+
entries: durableRecords,
|
|
463
|
+
segment: DefaultDurableSegment,
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
// evicts
|
|
467
|
+
const evictedKeys = keys(evictedRecords);
|
|
468
|
+
if (evictedKeys.length > 0) {
|
|
469
|
+
durableStoreOperations.push({
|
|
470
|
+
type: exports.DurableStoreOperationType.EvictEntries,
|
|
471
|
+
ids: evictedKeys,
|
|
472
|
+
segment: DefaultDurableSegment,
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
if (durableStoreOperations.length > 0) {
|
|
476
|
+
return durableStore.batchOperations(durableStoreOperations).catch(durableStoreErrorHandler);
|
|
459
477
|
}
|
|
460
478
|
return Promise.resolve();
|
|
461
479
|
}
|
|
@@ -634,13 +652,10 @@
|
|
|
634
652
|
};
|
|
635
653
|
const storeEvict = function (key) {
|
|
636
654
|
validateNotDisposed();
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
ingestStagingStore.evict(key);
|
|
655
|
+
if (ingestStagingStore === null) {
|
|
656
|
+
ingestStagingStore = new engine.Store();
|
|
640
657
|
}
|
|
641
|
-
|
|
642
|
-
// do not await
|
|
643
|
-
durableStore.evictEntries([key], DefaultDurableSegment).catch(durableStoreErrorHandler);
|
|
658
|
+
ingestStagingStore.evict(key);
|
|
644
659
|
};
|
|
645
660
|
const getNode = function (key) {
|
|
646
661
|
validateNotDisposed();
|
|
@@ -752,7 +767,7 @@
|
|
|
752
767
|
return buildStaleWhileRevalidateImplementation({
|
|
753
768
|
validateNotDisposed,
|
|
754
769
|
reviveSnapshotWithCachePolicy,
|
|
755
|
-
}, cachePolicy.
|
|
770
|
+
}, cachePolicy.staleDurationSeconds);
|
|
756
771
|
default: {
|
|
757
772
|
if (process.env.NODE_ENV !== 'production') {
|
|
758
773
|
throw new Error(`unrecognized cache policy: ${JSON.stringify(cachePolicy)}`);
|
|
@@ -465,7 +465,8 @@
|
|
|
465
465
|
return __assign({}, source);
|
|
466
466
|
}
|
|
467
467
|
function flushStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler) {
|
|
468
|
-
var durableRecords = create(
|
|
468
|
+
var durableRecords = create(null);
|
|
469
|
+
var evictedRecords = create(null);
|
|
469
470
|
var records = store.records, storeMetadata = store.metadata, visitedIds = store.visitedIds, refreshedIds = store.refreshedIds;
|
|
470
471
|
// TODO: W-8909393 Once metadata is stored in its own segment we need to
|
|
471
472
|
// call setEntries for the visitedIds on default segment and call setEntries
|
|
@@ -474,8 +475,9 @@
|
|
|
474
475
|
for (var i = 0, len = keys$1.length; i < len; i += 1) {
|
|
475
476
|
var key = keys$1[i];
|
|
476
477
|
var record = records[key];
|
|
477
|
-
// this record has been evicted,
|
|
478
|
+
// this record has been evicted, evict from DS
|
|
478
479
|
if (record === undefined) {
|
|
480
|
+
evictedRecords[key] = true;
|
|
479
481
|
continue;
|
|
480
482
|
}
|
|
481
483
|
var metadata = storeMetadata[key];
|
|
@@ -488,11 +490,27 @@
|
|
|
488
490
|
durableRecords[key].metadata = copy(metadata);
|
|
489
491
|
}
|
|
490
492
|
}
|
|
493
|
+
var durableStoreOperations = [];
|
|
494
|
+
// publishes
|
|
491
495
|
var recordKeys = keys(durableRecords);
|
|
492
496
|
if (recordKeys.length > 0) {
|
|
493
|
-
|
|
494
|
-
.
|
|
495
|
-
|
|
497
|
+
durableStoreOperations.push({
|
|
498
|
+
type: exports.DurableStoreOperationType.SetEntries,
|
|
499
|
+
entries: durableRecords,
|
|
500
|
+
segment: DefaultDurableSegment,
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
// evicts
|
|
504
|
+
var evictedKeys = keys(evictedRecords);
|
|
505
|
+
if (evictedKeys.length > 0) {
|
|
506
|
+
durableStoreOperations.push({
|
|
507
|
+
type: exports.DurableStoreOperationType.EvictEntries,
|
|
508
|
+
ids: evictedKeys,
|
|
509
|
+
segment: DefaultDurableSegment,
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
if (durableStoreOperations.length > 0) {
|
|
513
|
+
return durableStore.batchOperations(durableStoreOperations).catch(durableStoreErrorHandler);
|
|
496
514
|
}
|
|
497
515
|
return Promise.resolve();
|
|
498
516
|
}
|
|
@@ -673,13 +691,10 @@
|
|
|
673
691
|
};
|
|
674
692
|
var storeEvict = function (key) {
|
|
675
693
|
validateNotDisposed();
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
ingestStagingStore.evict(key);
|
|
694
|
+
if (ingestStagingStore === null) {
|
|
695
|
+
ingestStagingStore = new engine.Store();
|
|
679
696
|
}
|
|
680
|
-
|
|
681
|
-
// do not await
|
|
682
|
-
durableStore.evictEntries([key], DefaultDurableSegment).catch(durableStoreErrorHandler);
|
|
697
|
+
ingestStagingStore.evict(key);
|
|
683
698
|
};
|
|
684
699
|
var getNode = function (key) {
|
|
685
700
|
validateNotDisposed();
|
|
@@ -794,7 +809,7 @@
|
|
|
794
809
|
return buildStaleWhileRevalidateImplementation({
|
|
795
810
|
validateNotDisposed: validateNotDisposed,
|
|
796
811
|
reviveSnapshotWithCachePolicy: reviveSnapshotWithCachePolicy,
|
|
797
|
-
}, cachePolicy.
|
|
812
|
+
}, cachePolicy.staleDurationSeconds);
|
|
798
813
|
default: {
|
|
799
814
|
if (process.env.NODE_ENV !== 'production') {
|
|
800
815
|
throw new Error("unrecognized cache policy: " + JSON.stringify(cachePolicy));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvio/environments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.1",
|
|
4
4
|
"description": "Luvio Environments",
|
|
5
5
|
"main": "dist/umd/es2018/environments.js",
|
|
6
6
|
"module": "dist/es/es2018/environments.js",
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
"dist/"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@luvio/engine": "0.
|
|
19
|
+
"@luvio/engine": "0.59.1"
|
|
20
20
|
}
|
|
21
21
|
}
|