@luvio/environments 0.122.0 → 0.124.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/es/es2018/environments.js +8 -5
- package/dist/es/es2018/events.d.ts +6 -3
- package/dist/es/es2018/makeDurable/revive.d.ts +4 -2
- package/dist/umd/es2018/environments.js +8 -5
- package/dist/umd/es2018/events.d.ts +6 -3
- package/dist/umd/es2018/makeDurable/revive.d.ts +4 -2
- package/dist/umd/es5/environments.js +8 -5
- package/dist/umd/es5/events.d.ts +6 -3
- package/dist/umd/es5/makeDurable/revive.d.ts +4 -2
- package/package.json +4 -3
|
@@ -131,7 +131,7 @@ function publishDurableStoreEntries(durableRecords, publish, publishMetadata) {
|
|
|
131
131
|
*/
|
|
132
132
|
function reviveSnapshot(baseEnvironment, durableStore,
|
|
133
133
|
// TODO [W-10165787]: We should only allow Unfulfilled snapshot be passed in
|
|
134
|
-
unavailableSnapshot, durableStoreErrorHandler, buildL1Snapshot, reviveMetrics = {
|
|
134
|
+
unavailableSnapshot, durableStoreErrorHandler, buildL1Snapshot, reviveMetrics = { l2Trips: [] }) {
|
|
135
135
|
const { recordId, select, seenRecords, state } = unavailableSnapshot;
|
|
136
136
|
// L2 can only revive Unfulfilled snapshots that have a selector since they have the
|
|
137
137
|
// info needed to revive (like missingLinks) and rebuild. Otherwise return L1 snapshot.
|
|
@@ -147,9 +147,12 @@ unavailableSnapshot, durableStoreErrorHandler, buildL1Snapshot, reviveMetrics =
|
|
|
147
147
|
const keysToRevive = keys(keysToReviveSet);
|
|
148
148
|
const canonicalKeys = keysToRevive.map((x) => baseEnvironment.storeGetCanonicalKey(x));
|
|
149
149
|
const start = Date.now();
|
|
150
|
-
reviveMetrics
|
|
150
|
+
const { l2Trips } = reviveMetrics;
|
|
151
151
|
return durableStore.getEntries(canonicalKeys, DefaultDurableSegment).then((durableRecords) => {
|
|
152
|
-
|
|
152
|
+
l2Trips.push({
|
|
153
|
+
duration: Date.now() - start,
|
|
154
|
+
keysRequestedCount: canonicalKeys.length,
|
|
155
|
+
});
|
|
153
156
|
const { revivedKeys, hadUnexpectedShape } = publishDurableStoreEntries(durableRecords,
|
|
154
157
|
// TODO [W-10072584]: instead of implicitly using L1 we should take in
|
|
155
158
|
// publish and publishMetadata funcs, so callers can decide where to
|
|
@@ -699,9 +702,9 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
699
702
|
const revivedSnapshot = reviveSnapshot(environment, durableStore, snapshot, durableStoreErrorHandler, () => injectedStoreLookup(snapshot.select, snapshot.refresh)).then((result) => {
|
|
700
703
|
emitDurableEnvironmentAdapterEvent({
|
|
701
704
|
type: 'l2-revive-end',
|
|
705
|
+
snapshot: result.snapshot,
|
|
702
706
|
duration: Date.now() - start,
|
|
703
|
-
l2Trips: result.metrics.
|
|
704
|
-
l2Duration: result.metrics.l2ReadDuration,
|
|
707
|
+
l2Trips: result.metrics.l2Trips,
|
|
705
708
|
}, adapterRequestContext.eventObservers);
|
|
706
709
|
return result.snapshot;
|
|
707
710
|
});
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { EnvironmentAdapterEvent } from '@luvio/engine';
|
|
2
|
-
import type { LuvioAdapterEventObserver } from '@luvio/engine';
|
|
2
|
+
import type { LuvioAdapterEventObserver, Snapshot } from '@luvio/engine';
|
|
3
3
|
interface ReviveStartEvent {
|
|
4
4
|
type: 'l2-revive-start';
|
|
5
5
|
}
|
|
6
6
|
interface ReviveEndEvent {
|
|
7
7
|
type: 'l2-revive-end';
|
|
8
8
|
duration: number;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
snapshot: Snapshot<unknown, unknown>;
|
|
10
|
+
l2Trips: {
|
|
11
|
+
duration: number;
|
|
12
|
+
keysRequestedCount: number;
|
|
13
|
+
}[];
|
|
11
14
|
}
|
|
12
15
|
export declare type DurableEnvironmentAdapterEventData = ReviveStartEvent | ReviveEndEvent;
|
|
13
16
|
export declare function isDurableEnvironmentEvent(event: EnvironmentAdapterEvent<unknown>): event is EnvironmentAdapterEvent<DurableEnvironmentAdapterEventData>;
|
|
@@ -21,8 +21,10 @@ declare type ReviveResponse = {
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function publishDurableStoreEntries(durableRecords: DurableStoreEntries<unknown> | undefined, publish: (key: string, record: unknown) => void, publishMetadata: (key: string, metadata: StoreMetadata) => void): ReviveResponse;
|
|
23
23
|
interface ReviveMetrics {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
l2Trips: {
|
|
25
|
+
keysRequestedCount: number;
|
|
26
|
+
duration: number;
|
|
27
|
+
}[];
|
|
26
28
|
}
|
|
27
29
|
interface ReviveResult<D, V> {
|
|
28
30
|
snapshot: Snapshot<D, V>;
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
*/
|
|
136
136
|
function reviveSnapshot(baseEnvironment, durableStore,
|
|
137
137
|
// TODO [W-10165787]: We should only allow Unfulfilled snapshot be passed in
|
|
138
|
-
unavailableSnapshot, durableStoreErrorHandler, buildL1Snapshot, reviveMetrics = {
|
|
138
|
+
unavailableSnapshot, durableStoreErrorHandler, buildL1Snapshot, reviveMetrics = { l2Trips: [] }) {
|
|
139
139
|
const { recordId, select, seenRecords, state } = unavailableSnapshot;
|
|
140
140
|
// L2 can only revive Unfulfilled snapshots that have a selector since they have the
|
|
141
141
|
// info needed to revive (like missingLinks) and rebuild. Otherwise return L1 snapshot.
|
|
@@ -151,9 +151,12 @@
|
|
|
151
151
|
const keysToRevive = keys(keysToReviveSet);
|
|
152
152
|
const canonicalKeys = keysToRevive.map((x) => baseEnvironment.storeGetCanonicalKey(x));
|
|
153
153
|
const start = Date.now();
|
|
154
|
-
reviveMetrics
|
|
154
|
+
const { l2Trips } = reviveMetrics;
|
|
155
155
|
return durableStore.getEntries(canonicalKeys, DefaultDurableSegment).then((durableRecords) => {
|
|
156
|
-
|
|
156
|
+
l2Trips.push({
|
|
157
|
+
duration: Date.now() - start,
|
|
158
|
+
keysRequestedCount: canonicalKeys.length,
|
|
159
|
+
});
|
|
157
160
|
const { revivedKeys, hadUnexpectedShape } = publishDurableStoreEntries(durableRecords,
|
|
158
161
|
// TODO [W-10072584]: instead of implicitly using L1 we should take in
|
|
159
162
|
// publish and publishMetadata funcs, so callers can decide where to
|
|
@@ -703,9 +706,9 @@
|
|
|
703
706
|
const revivedSnapshot = reviveSnapshot(environment, durableStore, snapshot, durableStoreErrorHandler, () => injectedStoreLookup(snapshot.select, snapshot.refresh)).then((result) => {
|
|
704
707
|
emitDurableEnvironmentAdapterEvent({
|
|
705
708
|
type: 'l2-revive-end',
|
|
709
|
+
snapshot: result.snapshot,
|
|
706
710
|
duration: Date.now() - start,
|
|
707
|
-
l2Trips: result.metrics.
|
|
708
|
-
l2Duration: result.metrics.l2ReadDuration,
|
|
711
|
+
l2Trips: result.metrics.l2Trips,
|
|
709
712
|
}, adapterRequestContext.eventObservers);
|
|
710
713
|
return result.snapshot;
|
|
711
714
|
});
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { EnvironmentAdapterEvent } from '@luvio/engine';
|
|
2
|
-
import type { LuvioAdapterEventObserver } from '@luvio/engine';
|
|
2
|
+
import type { LuvioAdapterEventObserver, Snapshot } from '@luvio/engine';
|
|
3
3
|
interface ReviveStartEvent {
|
|
4
4
|
type: 'l2-revive-start';
|
|
5
5
|
}
|
|
6
6
|
interface ReviveEndEvent {
|
|
7
7
|
type: 'l2-revive-end';
|
|
8
8
|
duration: number;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
snapshot: Snapshot<unknown, unknown>;
|
|
10
|
+
l2Trips: {
|
|
11
|
+
duration: number;
|
|
12
|
+
keysRequestedCount: number;
|
|
13
|
+
}[];
|
|
11
14
|
}
|
|
12
15
|
export declare type DurableEnvironmentAdapterEventData = ReviveStartEvent | ReviveEndEvent;
|
|
13
16
|
export declare function isDurableEnvironmentEvent(event: EnvironmentAdapterEvent<unknown>): event is EnvironmentAdapterEvent<DurableEnvironmentAdapterEventData>;
|
|
@@ -21,8 +21,10 @@ declare type ReviveResponse = {
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function publishDurableStoreEntries(durableRecords: DurableStoreEntries<unknown> | undefined, publish: (key: string, record: unknown) => void, publishMetadata: (key: string, metadata: StoreMetadata) => void): ReviveResponse;
|
|
23
23
|
interface ReviveMetrics {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
l2Trips: {
|
|
25
|
+
keysRequestedCount: number;
|
|
26
|
+
duration: number;
|
|
27
|
+
}[];
|
|
26
28
|
}
|
|
27
29
|
interface ReviveResult<D, V> {
|
|
28
30
|
snapshot: Snapshot<D, V>;
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
// TODO [W-10165787]: We should only allow Unfulfilled snapshot be passed in
|
|
213
213
|
unavailableSnapshot, durableStoreErrorHandler, buildL1Snapshot, reviveMetrics) {
|
|
214
214
|
var _a;
|
|
215
|
-
if (reviveMetrics === void 0) { reviveMetrics = {
|
|
215
|
+
if (reviveMetrics === void 0) { reviveMetrics = { l2Trips: [] }; }
|
|
216
216
|
var recordId = unavailableSnapshot.recordId, select = unavailableSnapshot.select, seenRecords = unavailableSnapshot.seenRecords, state = unavailableSnapshot.state;
|
|
217
217
|
// L2 can only revive Unfulfilled snapshots that have a selector since they have the
|
|
218
218
|
// info needed to revive (like missingLinks) and rebuild. Otherwise return L1 snapshot.
|
|
@@ -228,10 +228,13 @@
|
|
|
228
228
|
var keysToRevive = keys(keysToReviveSet);
|
|
229
229
|
var canonicalKeys = keysToRevive.map(function (x) { return baseEnvironment.storeGetCanonicalKey(x); });
|
|
230
230
|
var start = Date.now();
|
|
231
|
-
reviveMetrics.
|
|
231
|
+
var l2Trips = reviveMetrics.l2Trips;
|
|
232
232
|
return durableStore.getEntries(canonicalKeys, DefaultDurableSegment).then(function (durableRecords) {
|
|
233
233
|
var _a;
|
|
234
|
-
|
|
234
|
+
l2Trips.push({
|
|
235
|
+
duration: Date.now() - start,
|
|
236
|
+
keysRequestedCount: canonicalKeys.length,
|
|
237
|
+
});
|
|
235
238
|
var _b = publishDurableStoreEntries(durableRecords,
|
|
236
239
|
// TODO [W-10072584]: instead of implicitly using L1 we should take in
|
|
237
240
|
// publish and publishMetadata funcs, so callers can decide where to
|
|
@@ -812,9 +815,9 @@
|
|
|
812
815
|
var revivedSnapshot = reviveSnapshot(environment, durableStore, snapshot, durableStoreErrorHandler, function () { return injectedStoreLookup(snapshot.select, snapshot.refresh); }).then(function (result) {
|
|
813
816
|
emitDurableEnvironmentAdapterEvent({
|
|
814
817
|
type: 'l2-revive-end',
|
|
818
|
+
snapshot: result.snapshot,
|
|
815
819
|
duration: Date.now() - start_1,
|
|
816
|
-
l2Trips: result.metrics.
|
|
817
|
-
l2Duration: result.metrics.l2ReadDuration,
|
|
820
|
+
l2Trips: result.metrics.l2Trips,
|
|
818
821
|
}, adapterRequestContext.eventObservers);
|
|
819
822
|
return result.snapshot;
|
|
820
823
|
});
|
package/dist/umd/es5/events.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { EnvironmentAdapterEvent } from '@luvio/engine';
|
|
2
|
-
import type { LuvioAdapterEventObserver } from '@luvio/engine';
|
|
2
|
+
import type { LuvioAdapterEventObserver, Snapshot } from '@luvio/engine';
|
|
3
3
|
interface ReviveStartEvent {
|
|
4
4
|
type: 'l2-revive-start';
|
|
5
5
|
}
|
|
6
6
|
interface ReviveEndEvent {
|
|
7
7
|
type: 'l2-revive-end';
|
|
8
8
|
duration: number;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
snapshot: Snapshot<unknown, unknown>;
|
|
10
|
+
l2Trips: {
|
|
11
|
+
duration: number;
|
|
12
|
+
keysRequestedCount: number;
|
|
13
|
+
}[];
|
|
11
14
|
}
|
|
12
15
|
export declare type DurableEnvironmentAdapterEventData = ReviveStartEvent | ReviveEndEvent;
|
|
13
16
|
export declare function isDurableEnvironmentEvent(event: EnvironmentAdapterEvent<unknown>): event is EnvironmentAdapterEvent<DurableEnvironmentAdapterEventData>;
|
|
@@ -21,8 +21,10 @@ declare type ReviveResponse = {
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function publishDurableStoreEntries(durableRecords: DurableStoreEntries<unknown> | undefined, publish: (key: string, record: unknown) => void, publishMetadata: (key: string, metadata: StoreMetadata) => void): ReviveResponse;
|
|
23
23
|
interface ReviveMetrics {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
l2Trips: {
|
|
25
|
+
keysRequestedCount: number;
|
|
26
|
+
duration: number;
|
|
27
|
+
}[];
|
|
26
28
|
}
|
|
27
29
|
interface ReviveResult<D, V> {
|
|
28
30
|
snapshot: Snapshot<D, V>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvio/environments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.124.0",
|
|
4
4
|
"description": "Luvio Environments",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"watch": "yarn build --watch"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@luvio/engine": "0.
|
|
26
|
+
"@luvio/engine": "0.124.0"
|
|
27
27
|
},
|
|
28
28
|
"bundlesize": [
|
|
29
29
|
{
|
|
@@ -40,5 +40,6 @@
|
|
|
40
40
|
]
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "50e7f51b6cf902290c846bc7ea661febc48fd145"
|
|
44
45
|
}
|