@absolutejs/sync 2.0.1 → 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/index.js CHANGED
@@ -1375,6 +1375,9 @@ var createSyncEngine = (options = {}) => {
1375
1375
  let mutationsFailed = 0;
1376
1376
  let mutationsRetried = 0;
1377
1377
  let mutationsInFlight = 0;
1378
+ let connectedSources = 0;
1379
+ let sourceChangesReceived = 0;
1380
+ let sourceLastChangeAt = null;
1378
1381
  const mutationWaiters = [];
1379
1382
  let mutationsQueued = 0;
1380
1383
  const activeFences = new Set;
@@ -2428,8 +2431,18 @@ var createSyncEngine = (options = {}) => {
2428
2431
  },
2429
2432
  applyChange: (table, change) => applyChange(table, change),
2430
2433
  connectSource: async (source) => {
2431
- await source.start((table, change) => applyChange(table, change));
2434
+ await source.start((table, change) => {
2435
+ sourceChangesReceived += 1;
2436
+ sourceLastChangeAt = Date.now();
2437
+ return applyChange(table, change);
2438
+ });
2439
+ connectedSources += 1;
2440
+ let stopped = false;
2432
2441
  return async () => {
2442
+ if (!stopped) {
2443
+ stopped = true;
2444
+ connectedSources -= 1;
2445
+ }
2433
2446
  await source.stop();
2434
2447
  };
2435
2448
  },
@@ -2990,6 +3003,12 @@ var createSyncEngine = (options = {}) => {
2990
3003
  schedules: {
2991
3004
  registered: schedules.size
2992
3005
  },
3006
+ source: {
3007
+ changesReceived: sourceChangesReceived,
3008
+ connected: connectedSources,
3009
+ lastChangeAgeMs: sourceLastChangeAt === null ? null : now - sourceLastChangeAt,
3010
+ lastChangeAt: sourceLastChangeAt
3011
+ },
2993
3012
  subscriptions: {
2994
3013
  byCollection,
2995
3014
  byTenant: Object.fromEntries(subscriptionsByTenant),
@@ -3486,5 +3505,5 @@ export {
3486
3505
  createPresenceHub
3487
3506
  };
3488
3507
 
3489
- //# debugId=657517E899F8FF7E64756E2164756E21
3508
+ //# debugId=B94BDA3C56450BBB64756E2164756E21
3490
3509
  //# sourceMappingURL=index.js.map