@luvio/environments 0.154.20 → 0.155.0
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/environments.js
CHANGED
|
@@ -278,7 +278,7 @@ class DurableTTLStore {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler, redirects, additionalDurableStoreOperations = [], enableDurableMetadataRefresh = false) {
|
|
281
|
+
function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler, redirects, shouldFlush, additionalDurableStoreOperations = [], enableDurableMetadataRefresh = false) {
|
|
282
282
|
const durableRecords = create(null);
|
|
283
283
|
const refreshedDurableRecords = create(null);
|
|
284
284
|
const evictedRecords = create(null);
|
|
@@ -306,7 +306,16 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
|
|
|
306
306
|
const entries = wasVisited === true || enableDurableMetadataRefresh === false
|
|
307
307
|
? durableRecords
|
|
308
308
|
: refreshedDurableRecords;
|
|
309
|
-
|
|
309
|
+
const { flushValue: flushValue, forceFlushMetadata: flushMetadata } = shouldFlush(key, record);
|
|
310
|
+
if (flushValue) {
|
|
311
|
+
setRecordTo(entries, key, record, metadata);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
// If the record is not to be flushed, we still need to update the metadata
|
|
315
|
+
if (flushMetadata === true) {
|
|
316
|
+
setRecordTo(refreshedDurableRecords, key, record, metadata);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
310
319
|
}
|
|
311
320
|
const durableStoreOperations = additionalDurableStoreOperations;
|
|
312
321
|
const recordKeys = keys(durableRecords);
|
|
@@ -510,7 +519,7 @@ function isUnfulfilledSnapshot(cachedSnapshotResult) {
|
|
|
510
519
|
* @param durableStore A DurableStore implementation
|
|
511
520
|
* @param instrumentation An instrumentation function implementation
|
|
512
521
|
*/
|
|
513
|
-
function makeDurable(environment, { durableStore, instrumentation, useRevivingStore, enableDurableMetadataRefresh = false, disableDeepFreeze = false, }) {
|
|
522
|
+
function makeDurable(environment, { durableStore, instrumentation, useRevivingStore, shouldFlush, enableDurableMetadataRefresh = false, disableDeepFreeze = false, }) {
|
|
514
523
|
// runtimes can choose to disable deepFreeze, e.g. headless mobile runtime
|
|
515
524
|
setBypassDeepFreeze(disableDeepFreeze);
|
|
516
525
|
let stagingStore = null;
|
|
@@ -717,7 +726,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
|
|
|
717
726
|
if (stagingStore === null) {
|
|
718
727
|
return Promise.resolve();
|
|
719
728
|
}
|
|
720
|
-
const promise = flushInMemoryStoreValuesToDurableStore(stagingStore, durableStore, durableStoreErrorHandler, new Map(pendingStoreRedirects), additionalDurableStoreOperations, enableDurableMetadataRefresh);
|
|
729
|
+
const promise = flushInMemoryStoreValuesToDurableStore(stagingStore, durableStore, durableStoreErrorHandler, new Map(pendingStoreRedirects), shouldFlush !== null && shouldFlush !== void 0 ? shouldFlush : (() => ({ flushValue: true })), additionalDurableStoreOperations, enableDurableMetadataRefresh);
|
|
721
730
|
pendingStoreRedirects.clear();
|
|
722
731
|
stagingStore = null;
|
|
723
732
|
return promise;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { DurableTTLOverride, DefaultDurableTTLOverride } from './DurableTTLStore
|
|
|
3
3
|
export { makeDurable, DurableEnvironment } from './makeDurable';
|
|
4
4
|
export { publishDurableStoreEntries } from './makeDurable/revive';
|
|
5
5
|
export { isDurableEnvironmentEvent } from './events';
|
|
6
|
+
export type { ShouldFlushFn } from './makeDurable/flush';
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { InMemoryStore } from '@luvio/engine';
|
|
2
2
|
import type { DurableStore, DurableStoreOperation } from '../DurableStore';
|
|
3
3
|
import type { DurableStoreRejectionHandler } from './error';
|
|
4
|
-
export
|
|
4
|
+
export type ShouldFlushFn = (key: string, data: unknown) => {
|
|
5
|
+
flushValue: boolean;
|
|
6
|
+
forceFlushMetadata?: true;
|
|
7
|
+
};
|
|
8
|
+
export declare function flushInMemoryStoreValuesToDurableStore(store: InMemoryStore, durableStore: DurableStore, durableStoreErrorHandler: DurableStoreRejectionHandler, redirects: Map<string, string>, shouldFlush: ShouldFlushFn, additionalDurableStoreOperations?: DurableStoreOperation<unknown>[], enableDurableMetadataRefresh?: boolean): Promise<void>;
|
|
@@ -2,6 +2,7 @@ import type { Environment, RecordSource, InMemoryStore } from '@luvio/engine';
|
|
|
2
2
|
import type { DurableStore, DurableStoreOperation } from './DurableStore';
|
|
3
3
|
import type { InstrumentationFunction } from './makeDurable/error';
|
|
4
4
|
import type { TTLOverridesMap } from './DurableTTLStore';
|
|
5
|
+
import { type ShouldFlushFn } from './makeDurable/flush';
|
|
5
6
|
export interface DurableEnvironment extends Environment {
|
|
6
7
|
/**
|
|
7
8
|
* Disposes the environment and detaches the durable store listener
|
|
@@ -42,6 +43,7 @@ interface MakeDurableOptions {
|
|
|
42
43
|
enableDurableMetadataRefresh?: boolean;
|
|
43
44
|
useRevivingStore?: boolean;
|
|
44
45
|
disableDeepFreeze?: boolean;
|
|
46
|
+
shouldFlush?: ShouldFlushFn;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
47
49
|
* Configures the environment to persist data into a durable store and attempt to resolve
|
|
@@ -52,5 +54,5 @@ interface MakeDurableOptions {
|
|
|
52
54
|
* @param durableStore A DurableStore implementation
|
|
53
55
|
* @param instrumentation An instrumentation function implementation
|
|
54
56
|
*/
|
|
55
|
-
export declare function makeDurable(environment: Environment, { durableStore, instrumentation, useRevivingStore, enableDurableMetadataRefresh, disableDeepFreeze, }: MakeDurableOptions): DurableEnvironment;
|
|
57
|
+
export declare function makeDurable(environment: Environment, { durableStore, instrumentation, useRevivingStore, shouldFlush, enableDurableMetadataRefresh, disableDeepFreeze, }: MakeDurableOptions): DurableEnvironment;
|
|
56
58
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvio/environments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.155.0",
|
|
4
4
|
"description": "Luvio Environments",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"watch": "yarn build --watch"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@luvio/engine": "^0.
|
|
30
|
+
"@luvio/engine": "^0.155.0"
|
|
31
31
|
},
|
|
32
32
|
"volta": {
|
|
33
33
|
"extends": "../../../package.json"
|