@powersync/service-core 0.0.0-dev-20240709124106 → 0.0.0-dev-20240718134716
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/CHANGELOG.md +34 -2
- package/dist/metrics/Metrics.d.ts +3 -4
- package/dist/metrics/Metrics.js +0 -51
- package/dist/metrics/Metrics.js.map +1 -1
- package/dist/replication/WalStream.js +8 -6
- package/dist/replication/WalStream.js.map +1 -1
- package/dist/routes/endpoints/socket-route.js +13 -4
- package/dist/routes/endpoints/socket-route.js.map +1 -1
- package/dist/routes/endpoints/sync-stream.js +14 -5
- package/dist/routes/endpoints/sync-stream.js.map +1 -1
- package/dist/routes/route-register.js +1 -0
- package/dist/routes/route-register.js.map +1 -1
- package/dist/sync/RequestTracker.d.ts +9 -0
- package/dist/sync/RequestTracker.js +20 -0
- package/dist/sync/RequestTracker.js.map +1 -0
- package/dist/sync/sync.d.ts +2 -0
- package/dist/sync/sync.js +31 -11
- package/dist/sync/sync.js.map +1 -1
- package/dist/sync/util.d.ts +2 -1
- package/dist/sync/util.js +2 -3
- package/dist/sync/util.js.map +1 -1
- package/dist/util/config/collectors/config-collector.d.ts +0 -12
- package/dist/util/config/collectors/config-collector.js +0 -43
- package/dist/util/config/collectors/config-collector.js.map +1 -1
- package/dist/util/config/compound-config-collector.d.ts +29 -3
- package/dist/util/config/compound-config-collector.js +69 -22
- package/dist/util/config/compound-config-collector.js.map +1 -1
- package/package.json +6 -8
- package/src/metrics/Metrics.ts +2 -67
- package/src/replication/WalStream.ts +10 -6
- package/src/routes/endpoints/socket-route.ts +14 -4
- package/src/routes/endpoints/sync-stream.ts +15 -5
- package/src/routes/route-register.ts +1 -0
- package/src/sync/RequestTracker.ts +21 -0
- package/src/sync/sync.ts +41 -11
- package/src/sync/util.ts +6 -3
- package/src/util/config/collectors/config-collector.ts +0 -48
- package/src/util/config/compound-config-collector.ts +87 -23
- package/test/src/sync.test.ts +8 -0
- package/test/src/util.ts +12 -6
- package/test/src/wal_stream.test.ts +16 -21
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -5,6 +5,7 @@ import { MONGO_STORAGE_FACTORY } from './util.js';
|
|
|
5
5
|
import { putOp, removeOp, walStreamTest } from './wal_stream_utils.js';
|
|
6
6
|
import { pgwireRows } from '@powersync/service-jpgwire';
|
|
7
7
|
import { Metrics } from '@/metrics/Metrics.js';
|
|
8
|
+
import { container } from '@powersync/lib-services-framework';
|
|
8
9
|
|
|
9
10
|
type StorageFactory = () => Promise<BucketStorageFactory>;
|
|
10
11
|
|
|
@@ -41,10 +42,9 @@ bucket_definitions:
|
|
|
41
42
|
|
|
42
43
|
await context.replicateSnapshot();
|
|
43
44
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const startTxCount =
|
|
47
|
-
(await Metrics.getInstance().getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
45
|
+
const metrics = container.getImplementation(Metrics);
|
|
46
|
+
const startRowCount = (await metrics.getMetricValueForTests('powersync_rows_replicated_total')) ?? 0;
|
|
47
|
+
const startTxCount = (await metrics.getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
48
48
|
|
|
49
49
|
context.startStreaming();
|
|
50
50
|
|
|
@@ -59,9 +59,8 @@ bucket_definitions:
|
|
|
59
59
|
expect(data).toMatchObject([
|
|
60
60
|
putOp('test_data', { id: test_id, description: 'test1', num: 1152921504606846976n })
|
|
61
61
|
]);
|
|
62
|
-
const endRowCount = (await
|
|
63
|
-
const endTxCount =
|
|
64
|
-
(await Metrics.getInstance().getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
62
|
+
const endRowCount = (await metrics.getMetricValueForTests('powersync_rows_replicated_total')) ?? 0;
|
|
63
|
+
const endTxCount = (await metrics.getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
65
64
|
expect(endRowCount - startRowCount).toEqual(1);
|
|
66
65
|
expect(endTxCount - startTxCount).toEqual(1);
|
|
67
66
|
})
|
|
@@ -83,10 +82,9 @@ bucket_definitions:
|
|
|
83
82
|
|
|
84
83
|
await context.replicateSnapshot();
|
|
85
84
|
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const startTxCount =
|
|
89
|
-
(await Metrics.getInstance().getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
85
|
+
const metrics = container.getImplementation(Metrics);
|
|
86
|
+
const startRowCount = (await metrics.getMetricValueForTests('powersync_rows_replicated_total')) ?? 0;
|
|
87
|
+
const startTxCount = (await metrics.getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
90
88
|
|
|
91
89
|
context.startStreaming();
|
|
92
90
|
|
|
@@ -97,9 +95,8 @@ bucket_definitions:
|
|
|
97
95
|
const data = await context.getBucketData('global[]');
|
|
98
96
|
|
|
99
97
|
expect(data).toMatchObject([putOp('test_DATA', { id: test_id, description: 'test1' })]);
|
|
100
|
-
const endRowCount = (await
|
|
101
|
-
const endTxCount =
|
|
102
|
-
(await Metrics.getInstance().getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
98
|
+
const endRowCount = (await metrics.getMetricValueForTests('powersync_rows_replicated_total')) ?? 0;
|
|
99
|
+
const endTxCount = (await metrics.getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
103
100
|
expect(endRowCount - startRowCount).toEqual(1);
|
|
104
101
|
expect(endTxCount - startTxCount).toEqual(1);
|
|
105
102
|
})
|
|
@@ -293,10 +290,9 @@ bucket_definitions:
|
|
|
293
290
|
|
|
294
291
|
await context.replicateSnapshot();
|
|
295
292
|
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
const startTxCount =
|
|
299
|
-
(await Metrics.getInstance().getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
293
|
+
const metrics = container.getImplementation(Metrics);
|
|
294
|
+
const startRowCount = (await metrics.getMetricValueForTests('powersync_rows_replicated_total')) ?? 0;
|
|
295
|
+
const startTxCount = (await metrics.getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
300
296
|
|
|
301
297
|
context.startStreaming();
|
|
302
298
|
|
|
@@ -307,9 +303,8 @@ bucket_definitions:
|
|
|
307
303
|
const data = await context.getBucketData('global[]');
|
|
308
304
|
|
|
309
305
|
expect(data).toMatchObject([]);
|
|
310
|
-
const endRowCount = (await
|
|
311
|
-
const endTxCount =
|
|
312
|
-
(await Metrics.getInstance().getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
306
|
+
const endRowCount = (await metrics.getMetricValueForTests('powersync_rows_replicated_total')) ?? 0;
|
|
307
|
+
const endTxCount = (await metrics.getMetricValueForTests('powersync_transactions_replicated_total')) ?? 0;
|
|
313
308
|
|
|
314
309
|
// There was a transaction, but we should not replicate any actual data
|
|
315
310
|
expect(endRowCount - startRowCount).toEqual(0);
|