@absolutejs/sync 2.0.0 → 2.1.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/testing.js CHANGED
@@ -826,6 +826,9 @@ var createSyncEngine = (options = {}) => {
826
826
  let mutationsFailed = 0;
827
827
  let mutationsRetried = 0;
828
828
  let mutationsInFlight = 0;
829
+ let connectedSources = 0;
830
+ let sourceChangesReceived = 0;
831
+ let sourceLastChangeAt = null;
829
832
  const mutationWaiters = [];
830
833
  let mutationsQueued = 0;
831
834
  const activeFences = new Set;
@@ -1879,8 +1882,18 @@ var createSyncEngine = (options = {}) => {
1879
1882
  },
1880
1883
  applyChange: (table, change) => applyChange(table, change),
1881
1884
  connectSource: async (source) => {
1882
- await source.start((table, change) => applyChange(table, change));
1885
+ await source.start((table, change) => {
1886
+ sourceChangesReceived += 1;
1887
+ sourceLastChangeAt = Date.now();
1888
+ return applyChange(table, change);
1889
+ });
1890
+ connectedSources += 1;
1891
+ let stopped = false;
1883
1892
  return async () => {
1893
+ if (!stopped) {
1894
+ stopped = true;
1895
+ connectedSources -= 1;
1896
+ }
1884
1897
  await source.stop();
1885
1898
  };
1886
1899
  },
@@ -2441,6 +2454,12 @@ var createSyncEngine = (options = {}) => {
2441
2454
  schedules: {
2442
2455
  registered: schedules.size
2443
2456
  },
2457
+ source: {
2458
+ changesReceived: sourceChangesReceived,
2459
+ connected: connectedSources,
2460
+ lastChangeAgeMs: sourceLastChangeAt === null ? null : now - sourceLastChangeAt,
2461
+ lastChangeAt: sourceLastChangeAt
2462
+ },
2444
2463
  subscriptions: {
2445
2464
  byCollection,
2446
2465
  byTenant: Object.fromEntries(subscriptionsByTenant),
@@ -2553,5 +2572,5 @@ export {
2553
2572
  createTestEngine
2554
2573
  };
2555
2574
 
2556
- //# debugId=2AB81FA5B279855564756E2164756E21
2575
+ //# debugId=9F1D5180F1BD937C64756E2164756E21
2557
2576
  //# sourceMappingURL=testing.js.map