@luvio/environments 0.73.2 → 0.73.3

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.
@@ -548,12 +548,9 @@ function makeDurable(environment, { durableStore, instrumentation }) {
548
548
  };
549
549
  const storeBroadcast = function (_rebuildSnapshot, _snapshotDataAvailable) {
550
550
  validateNotDisposed();
551
- // for our environment we basically want a broadcast to be a "durable store broadcast",
552
- // so we flush staging store to L2, which will cause the onChanged handler to fire
553
- // which will revive records to the main L1 store and call the base storeBroadcast
554
- // don't await the DS write - DS implementation will take care of R/W
555
- // synchronization
556
- publishChangesToDurableStore();
551
+ // no-op here and wait for the L2 flush to happen in handleSuccessResponse,
552
+ // that flush will cause the onChanged handler to fire which will revive
553
+ // records to the main L1 store and call the base storeBroadcast
557
554
  };
558
555
  const publishChangesToDurableStore = function () {
559
556
  validateNotDisposed();
@@ -697,14 +694,24 @@ function makeDurable(environment, { durableStore, instrumentation }) {
697
694
  ingestStagingStore.records = existingRecords;
698
695
  }
699
696
  const snapshotFromMemoryIngest = ingestAndBroadcastFunc();
700
- if (snapshotFromMemoryIngest === undefined) {
701
- return undefined;
702
- }
703
- if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
697
+ // now that ingestion is done flush staging store values to L2
698
+ return publishChangesToDurableStore().then(() => {
699
+ if (snapshotFromMemoryIngest === undefined) {
700
+ return undefined;
701
+ }
702
+ if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
703
+ return snapshotFromMemoryIngest;
704
+ }
705
+ // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
706
+ return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, () => environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh));
707
+ });
708
+ };
709
+ const handleErrorResponse = function (ingestAndBroadcastFunc) {
710
+ validateNotDisposed();
711
+ const snapshotFromMemoryIngest = ingestAndBroadcastFunc();
712
+ return publishChangesToDurableStore().then(() => {
704
713
  return snapshotFromMemoryIngest;
705
- }
706
- // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
707
- return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, () => environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh));
714
+ });
708
715
  };
709
716
  environment.defaultCachePolicy = buildStaleWhileRevalidateImplementation(Number.MAX_SAFE_INTEGER);
710
717
  return create(environment, {
@@ -729,6 +736,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
729
736
  getIngestStagingStoreRecords: { value: getIngestStagingStoreRecords },
730
737
  getIngestStagingStoreMetadata: { value: getIngestStagingStoreMetadata },
731
738
  handleSuccessResponse: { value: handleSuccessResponse },
739
+ handleErrorResponse: { value: handleErrorResponse },
732
740
  });
733
741
  }
734
742
 
@@ -552,12 +552,9 @@
552
552
  };
553
553
  const storeBroadcast = function (_rebuildSnapshot, _snapshotDataAvailable) {
554
554
  validateNotDisposed();
555
- // for our environment we basically want a broadcast to be a "durable store broadcast",
556
- // so we flush staging store to L2, which will cause the onChanged handler to fire
557
- // which will revive records to the main L1 store and call the base storeBroadcast
558
- // don't await the DS write - DS implementation will take care of R/W
559
- // synchronization
560
- publishChangesToDurableStore();
555
+ // no-op here and wait for the L2 flush to happen in handleSuccessResponse,
556
+ // that flush will cause the onChanged handler to fire which will revive
557
+ // records to the main L1 store and call the base storeBroadcast
561
558
  };
562
559
  const publishChangesToDurableStore = function () {
563
560
  validateNotDisposed();
@@ -701,14 +698,24 @@
701
698
  ingestStagingStore.records = existingRecords;
702
699
  }
703
700
  const snapshotFromMemoryIngest = ingestAndBroadcastFunc();
704
- if (snapshotFromMemoryIngest === undefined) {
705
- return undefined;
706
- }
707
- if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
701
+ // now that ingestion is done flush staging store values to L2
702
+ return publishChangesToDurableStore().then(() => {
703
+ if (snapshotFromMemoryIngest === undefined) {
704
+ return undefined;
705
+ }
706
+ if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
707
+ return snapshotFromMemoryIngest;
708
+ }
709
+ // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
710
+ return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, () => environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh));
711
+ });
712
+ };
713
+ const handleErrorResponse = function (ingestAndBroadcastFunc) {
714
+ validateNotDisposed();
715
+ const snapshotFromMemoryIngest = ingestAndBroadcastFunc();
716
+ return publishChangesToDurableStore().then(() => {
708
717
  return snapshotFromMemoryIngest;
709
- }
710
- // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
711
- return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, () => environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh));
718
+ });
712
719
  };
713
720
  environment.defaultCachePolicy = engine.buildStaleWhileRevalidateImplementation(Number.MAX_SAFE_INTEGER);
714
721
  return create(environment, {
@@ -733,6 +740,7 @@
733
740
  getIngestStagingStoreRecords: { value: getIngestStagingStoreRecords },
734
741
  getIngestStagingStoreMetadata: { value: getIngestStagingStoreMetadata },
735
742
  handleSuccessResponse: { value: handleSuccessResponse },
743
+ handleErrorResponse: { value: handleErrorResponse },
736
744
  });
737
745
  }
738
746
 
@@ -590,12 +590,9 @@
590
590
  };
591
591
  var storeBroadcast = function (_rebuildSnapshot, _snapshotDataAvailable) {
592
592
  validateNotDisposed();
593
- // for our environment we basically want a broadcast to be a "durable store broadcast",
594
- // so we flush staging store to L2, which will cause the onChanged handler to fire
595
- // which will revive records to the main L1 store and call the base storeBroadcast
596
- // don't await the DS write - DS implementation will take care of R/W
597
- // synchronization
598
- publishChangesToDurableStore();
593
+ // no-op here and wait for the L2 flush to happen in handleSuccessResponse,
594
+ // that flush will cause the onChanged handler to fire which will revive
595
+ // records to the main L1 store and call the base storeBroadcast
599
596
  };
600
597
  var publishChangesToDurableStore = function () {
601
598
  validateNotDisposed();
@@ -738,15 +735,25 @@
738
735
  ingestStagingStore.records = existingRecords;
739
736
  }
740
737
  var snapshotFromMemoryIngest = ingestAndBroadcastFunc();
741
- if (snapshotFromMemoryIngest === undefined) {
742
- return undefined;
743
- }
744
- if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
738
+ // now that ingestion is done flush staging store values to L2
739
+ return publishChangesToDurableStore().then(function () {
740
+ if (snapshotFromMemoryIngest === undefined) {
741
+ return undefined;
742
+ }
743
+ if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
744
+ return snapshotFromMemoryIngest;
745
+ }
746
+ // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
747
+ return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, function () {
748
+ return environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh);
749
+ });
750
+ });
751
+ };
752
+ var handleErrorResponse = function (ingestAndBroadcastFunc) {
753
+ validateNotDisposed();
754
+ var snapshotFromMemoryIngest = ingestAndBroadcastFunc();
755
+ return publishChangesToDurableStore().then(function () {
745
756
  return snapshotFromMemoryIngest;
746
- }
747
- // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
748
- return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, function () {
749
- return environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh);
750
757
  });
751
758
  };
752
759
  environment.defaultCachePolicy = engine.buildStaleWhileRevalidateImplementation(Number.MAX_SAFE_INTEGER);
@@ -772,6 +779,7 @@
772
779
  getIngestStagingStoreRecords: { value: getIngestStagingStoreRecords },
773
780
  getIngestStagingStoreMetadata: { value: getIngestStagingStoreMetadata },
774
781
  handleSuccessResponse: { value: handleSuccessResponse },
782
+ handleErrorResponse: { value: handleErrorResponse },
775
783
  });
776
784
  }
777
785
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luvio/environments",
3
- "version": "0.73.2",
3
+ "version": "0.73.3",
4
4
  "description": "Luvio Environments",
5
5
  "main": "dist/umd/es2018/environments.js",
6
6
  "module": "dist/es/es2018/environments.js",
@@ -26,6 +26,6 @@
26
26
  "dist/"
27
27
  ],
28
28
  "dependencies": {
29
- "@luvio/engine": "0.73.2"
29
+ "@luvio/engine": "0.73.3"
30
30
  }
31
31
  }