@powersync/service-core 0.1.1 → 0.1.2
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/metrics/Metrics.js.map +1 -1
- package/dist/replication/ErrorRateLimiter.js +2 -1
- package/dist/replication/ErrorRateLimiter.js.map +1 -1
- package/dist/routes/router.d.ts +1 -0
- package/dist/routes/socket-route.js +1 -1
- package/dist/routes/socket-route.js.map +1 -1
- package/dist/storage/MongoBucketStorage.js +1 -1
- package/dist/storage/MongoBucketStorage.js.map +1 -1
- package/dist/storage/mongo/MongoBucketBatch.js +2 -5
- package/dist/storage/mongo/MongoBucketBatch.js.map +1 -1
- package/dist/storage/mongo/PersistedBatch.d.ts +4 -0
- package/dist/storage/mongo/PersistedBatch.js +15 -2
- package/dist/storage/mongo/PersistedBatch.js.map +1 -1
- package/dist/storage/mongo/db.js +0 -3
- package/dist/storage/mongo/db.js.map +1 -1
- package/dist/storage/mongo/util.js +1 -1
- package/dist/util/config/compound-config-collector.js.map +1 -1
- package/package.json +5 -5
- package/src/metrics/Metrics.ts +5 -3
- package/src/replication/ErrorRateLimiter.ts +2 -1
- package/src/routes/router.ts +1 -0
- package/src/routes/socket-route.ts +1 -1
- package/src/storage/MongoBucketStorage.ts +2 -2
- package/src/storage/mongo/MongoBucketBatch.ts +2 -4
- package/src/storage/mongo/PersistedBatch.ts +25 -2
- package/src/storage/mongo/db.ts +0 -3
- package/src/storage/mongo/util.ts +1 -1
- package/src/util/config/compound-config-collector.ts +2 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -2,6 +2,7 @@ import { JSONBig } from '@powersync/service-jsonbig';
|
|
|
2
2
|
import { EvaluatedParameters, EvaluatedRow } from '@powersync/service-sync-rules';
|
|
3
3
|
import * as bson from 'bson';
|
|
4
4
|
import * as mongo from 'mongodb';
|
|
5
|
+
import * as micro from '@journeyapps-platform/micro';
|
|
5
6
|
|
|
6
7
|
import * as util from '@/util/util-index.js';
|
|
7
8
|
import { SourceTable } from '../SourceTable.js';
|
|
@@ -42,6 +43,11 @@ export class PersistedBatch {
|
|
|
42
43
|
bucketParameters: mongo.AnyBulkWriteOperation<BucketParameterDocument>[] = [];
|
|
43
44
|
currentData: mongo.AnyBulkWriteOperation<CurrentDataDocument>[] = [];
|
|
44
45
|
|
|
46
|
+
/**
|
|
47
|
+
* For debug logging only.
|
|
48
|
+
*/
|
|
49
|
+
debugLastOpId: bigint | null = null;
|
|
50
|
+
|
|
45
51
|
/**
|
|
46
52
|
* Very rough estimate of transaction size.
|
|
47
53
|
*/
|
|
@@ -75,13 +81,16 @@ export class PersistedBatch {
|
|
|
75
81
|
const checksum = util.hashData(k.table, k.id, recordData);
|
|
76
82
|
this.currentSize += recordData.length + 200;
|
|
77
83
|
|
|
84
|
+
const op_id = options.op_seq.next();
|
|
85
|
+
this.debugLastOpId = op_id;
|
|
86
|
+
|
|
78
87
|
this.bucketData.push({
|
|
79
88
|
insertOne: {
|
|
80
89
|
document: {
|
|
81
90
|
_id: {
|
|
82
91
|
g: this.group_id,
|
|
83
92
|
b: k.bucket,
|
|
84
|
-
o:
|
|
93
|
+
o: op_id
|
|
85
94
|
},
|
|
86
95
|
op: 'PUT',
|
|
87
96
|
source_table: options.table.id,
|
|
@@ -97,13 +106,17 @@ export class PersistedBatch {
|
|
|
97
106
|
|
|
98
107
|
for (let bd of remaining_buckets.values()) {
|
|
99
108
|
// REMOVE
|
|
109
|
+
|
|
110
|
+
const op_id = options.op_seq.next();
|
|
111
|
+
this.debugLastOpId = op_id;
|
|
112
|
+
|
|
100
113
|
this.bucketData.push({
|
|
101
114
|
insertOne: {
|
|
102
115
|
document: {
|
|
103
116
|
_id: {
|
|
104
117
|
g: this.group_id,
|
|
105
118
|
b: bd.bucket,
|
|
106
|
-
o:
|
|
119
|
+
o: op_id
|
|
107
120
|
},
|
|
108
121
|
op: 'REMOVE',
|
|
109
122
|
source_table: options.table.id,
|
|
@@ -145,7 +158,9 @@ export class PersistedBatch {
|
|
|
145
158
|
const binLookup = serializeLookup(result.lookup);
|
|
146
159
|
const hex = binLookup.toString('base64');
|
|
147
160
|
remaining_lookups.delete(hex);
|
|
161
|
+
|
|
148
162
|
const op_id = data.op_seq.next();
|
|
163
|
+
this.debugLastOpId = op_id;
|
|
149
164
|
this.bucketParameters.push({
|
|
150
165
|
insertOne: {
|
|
151
166
|
document: {
|
|
@@ -167,6 +182,7 @@ export class PersistedBatch {
|
|
|
167
182
|
// 2. "REMOVE" entries for any lookup not touched.
|
|
168
183
|
for (let lookup of remaining_lookups.values()) {
|
|
169
184
|
const op_id = data.op_seq.next();
|
|
185
|
+
this.debugLastOpId = op_id;
|
|
170
186
|
this.bucketParameters.push({
|
|
171
187
|
insertOne: {
|
|
172
188
|
document: {
|
|
@@ -237,9 +253,16 @@ export class PersistedBatch {
|
|
|
237
253
|
});
|
|
238
254
|
}
|
|
239
255
|
|
|
256
|
+
micro.logger.info(
|
|
257
|
+
`powersync_${this.group_id} Flushed ${this.bucketData.length} + ${this.bucketParameters.length} + ${
|
|
258
|
+
this.currentData.length
|
|
259
|
+
} updates, ${Math.round(this.currentSize / 1024)}kb. Last op_id: ${this.debugLastOpId}`
|
|
260
|
+
);
|
|
261
|
+
|
|
240
262
|
this.bucketData = [];
|
|
241
263
|
this.bucketParameters = [];
|
|
242
264
|
this.currentData = [];
|
|
243
265
|
this.currentSize = 0;
|
|
266
|
+
this.debugLastOpId = null;
|
|
244
267
|
}
|
|
245
268
|
}
|
package/src/storage/mongo/db.ts
CHANGED
|
@@ -45,9 +45,6 @@ export class PowerSyncMongo {
|
|
|
45
45
|
this.client = client;
|
|
46
46
|
|
|
47
47
|
const db = client.db(options?.database, {
|
|
48
|
-
// Note this issue with useBigInt64: https://jira.mongodb.org/browse/NODE-6165
|
|
49
|
-
// Unfortunately there is no workaround if we want to continue using bigint.
|
|
50
|
-
// We selectively disable this in individual queries where we don't need that.
|
|
51
48
|
...BSON_DESERIALIZE_OPTIONS
|
|
52
49
|
});
|
|
53
50
|
this.db = db;
|
|
@@ -121,7 +121,8 @@ export class CompoundConfigCollector {
|
|
|
121
121
|
migrations: baseConfig.migrations,
|
|
122
122
|
telemetry: {
|
|
123
123
|
disable_telemetry_sharing: baseConfig.telemetry?.disable_telemetry_sharing ?? false,
|
|
124
|
-
internal_service_endpoint:
|
|
124
|
+
internal_service_endpoint:
|
|
125
|
+
baseConfig.telemetry?.internal_service_endpoint ?? 'https://pulse.journeyapps.com/v1/metrics'
|
|
125
126
|
},
|
|
126
127
|
slot_name_prefix: connections[0]?.slot_name_prefix ?? 'powersync_'
|
|
127
128
|
};
|