@powersync/service-core 0.2.0 → 0.2.1
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 +8 -0
- package/dist/storage/BucketStorage.d.ts +6 -1
- package/dist/storage/BucketStorage.js.map +1 -1
- package/dist/storage/ChecksumCache.d.ts +50 -0
- package/dist/storage/ChecksumCache.js +234 -0
- package/dist/storage/ChecksumCache.js.map +1 -0
- package/dist/storage/mongo/MongoSyncBucketStorage.d.ts +3 -1
- package/dist/storage/mongo/MongoSyncBucketStorage.js +26 -14
- package/dist/storage/mongo/MongoSyncBucketStorage.js.map +1 -1
- package/dist/sync/sync.js +32 -21
- package/dist/sync/sync.js.map +1 -1
- package/dist/util/utils.d.ts +6 -3
- package/dist/util/utils.js +32 -15
- package/dist/util/utils.js.map +1 -1
- package/package.json +6 -5
- package/src/storage/BucketStorage.ts +6 -1
- package/src/storage/ChecksumCache.ts +294 -0
- package/src/storage/mongo/MongoSyncBucketStorage.ts +31 -15
- package/src/sync/sync.ts +44 -37
- package/src/util/utils.ts +36 -16
- package/test/src/__snapshots__/sync.test.ts.snap +14 -2
- package/test/src/checksum_cache.test.ts +436 -0
- package/test/src/data_storage.test.ts +3 -3
- package/test/src/large_batch.test.ts +4 -4
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -252,7 +252,7 @@ bucket_definitions:
|
|
|
252
252
|
{ op: 'REMOVE', object_id: 'test1', checksum: c2 }
|
|
253
253
|
]);
|
|
254
254
|
|
|
255
|
-
const checksums = await storage.getChecksums(checkpoint, ['global[]']);
|
|
255
|
+
const checksums = [...(await storage.getChecksums(checkpoint, ['global[]'])).values()];
|
|
256
256
|
expect(checksums).toEqual([
|
|
257
257
|
{
|
|
258
258
|
bucket: 'global[]',
|
|
@@ -599,7 +599,7 @@ bucket_definitions:
|
|
|
599
599
|
{ op: 'REMOVE', object_id: 'test1', checksum: c2 }
|
|
600
600
|
]);
|
|
601
601
|
|
|
602
|
-
const checksums = await storage.getChecksums(checkpoint, ['global[]']);
|
|
602
|
+
const checksums = [...(await storage.getChecksums(checkpoint, ['global[]'])).values()];
|
|
603
603
|
expect(checksums).toEqual([
|
|
604
604
|
{
|
|
605
605
|
bucket: 'global[]',
|
|
@@ -713,7 +713,7 @@ bucket_definitions:
|
|
|
713
713
|
{ op: 'REMOVE', object_id: 'test1', checksum: c2 }
|
|
714
714
|
]);
|
|
715
715
|
|
|
716
|
-
const checksums = await storage.getChecksums(checkpoint, ['global[]']);
|
|
716
|
+
const checksums = [...(await storage.getChecksums(checkpoint, ['global[]'])).values()];
|
|
717
717
|
expect(checksums).toEqual([
|
|
718
718
|
{
|
|
719
719
|
bucket: 'global[]',
|
|
@@ -50,7 +50,7 @@ function defineBatchTests(factory: StorageFactory) {
|
|
|
50
50
|
const duration = Date.now() - start;
|
|
51
51
|
const used = Math.round(process.memoryUsage().heapUsed / 1024 / 1024);
|
|
52
52
|
const checksum = await context.storage!.getChecksums(checkpoint, ['global[]']);
|
|
53
|
-
expect(checksum[
|
|
53
|
+
expect(checksum.get('global[]')!.count).toEqual(operation_count);
|
|
54
54
|
const perSecond = Math.round((operation_count / duration) * 1000);
|
|
55
55
|
console.log(`${operation_count} ops in ${duration}ms ${perSecond} ops/s. ${used}MB heap`);
|
|
56
56
|
}),
|
|
@@ -101,7 +101,7 @@ function defineBatchTests(factory: StorageFactory) {
|
|
|
101
101
|
const checkpoint = await context.getCheckpoint({ timeout: 100_000 });
|
|
102
102
|
const duration = Date.now() - start;
|
|
103
103
|
const checksum = await context.storage!.getChecksums(checkpoint, ['global[]']);
|
|
104
|
-
expect(checksum[
|
|
104
|
+
expect(checksum.get('global[]')!.count).toEqual(operation_count);
|
|
105
105
|
const perSecond = Math.round((operation_count / duration) * 1000);
|
|
106
106
|
console.log(`${operation_count} ops in ${duration}ms ${perSecond} ops/s.`);
|
|
107
107
|
printMemoryUsage();
|
|
@@ -157,7 +157,7 @@ function defineBatchTests(factory: StorageFactory) {
|
|
|
157
157
|
const duration = Date.now() - start;
|
|
158
158
|
const used = Math.round(process.memoryUsage().heapUsed / 1024 / 1024);
|
|
159
159
|
const checksum = await context.storage!.getChecksums(checkpoint, ['global[]']);
|
|
160
|
-
expect(checksum[
|
|
160
|
+
expect(checksum.get('global[]')!.count).toEqual(operationCount);
|
|
161
161
|
const perSecond = Math.round((operationCount / duration) * 1000);
|
|
162
162
|
// This number depends on the test machine, so we keep the test significantly
|
|
163
163
|
// lower than expected numbers.
|
|
@@ -174,7 +174,7 @@ function defineBatchTests(factory: StorageFactory) {
|
|
|
174
174
|
const truncateDuration = Date.now() - truncateStart;
|
|
175
175
|
|
|
176
176
|
const checksum2 = await context.storage!.getChecksums(checkpoint2, ['global[]']);
|
|
177
|
-
const truncateCount = checksum2[
|
|
177
|
+
const truncateCount = checksum2.get('global[]')!.count - checksum.get('global[]')!.count;
|
|
178
178
|
expect(truncateCount).toEqual(numTransactions * perTransaction);
|
|
179
179
|
const truncatePerSecond = Math.round((truncateCount / truncateDuration) * 1000);
|
|
180
180
|
console.log(`Truncated ${truncateCount} ops in ${truncateDuration}ms ${truncatePerSecond} ops/s. ${used}MB heap`);
|