@powersync/service-module-mysql 0.0.0-dev-20260602073133 → 0.0.0-dev-20260803144812
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 +82 -4
- package/dist/api/MySQLRouteAPIAdapter.d.ts +3 -3
- package/dist/api/MySQLRouteAPIAdapter.js +3 -2
- package/dist/api/MySQLRouteAPIAdapter.js.map +1 -1
- package/dist/common/schema-utils.js +4 -0
- package/dist/common/schema-utils.js.map +1 -1
- package/dist/replication/BinLogReplicationJob.d.ts +1 -1
- package/dist/replication/BinLogReplicationJob.js +3 -3
- package/dist/replication/BinLogReplicationJob.js.map +1 -1
- package/dist/replication/BinLogReplicator.js +1 -1
- package/dist/replication/BinLogReplicator.js.map +1 -1
- package/dist/replication/BinLogStream.js +9 -9
- package/dist/replication/BinLogStream.js.map +1 -1
- package/package.json +10 -20
- package/src/api/MySQLRouteAPIAdapter.ts +6 -5
- package/src/common/schema-utils.ts +8 -0
- package/src/replication/BinLogReplicationJob.ts +3 -3
- package/src/replication/BinLogReplicator.ts +1 -1
- package/src/replication/BinLogStream.ts +9 -9
- package/test/src/BinlogStreamUtils.ts +23 -23
- package/tsconfig.json +0 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -33,7 +33,7 @@ export class BinlogStreamTestContext {
|
|
|
33
33
|
private streamPromise?: Promise<void>;
|
|
34
34
|
public storage?: SyncRulesBucketStorage;
|
|
35
35
|
private replicationDone = false;
|
|
36
|
-
private syncRulesContent?: storage.
|
|
36
|
+
private syncRulesContent?: storage.PersistedSyncConfigContent;
|
|
37
37
|
|
|
38
38
|
static async open(factory: storage.TestStorageFactory, options?: { doNotClear?: boolean }) {
|
|
39
39
|
const f = await factory({ doNotClear: options?.doNotClear });
|
|
@@ -71,38 +71,38 @@ export class BinlogStreamTestContext {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
async updateSyncRules(content: string): Promise<SyncRulesBucketStorage> {
|
|
74
|
-
const
|
|
74
|
+
const replicationStream = await this.factory.updateSyncRules(
|
|
75
75
|
updateSyncRulesFromYaml(content, { validate: true, storageVersion: LEGACY_STORAGE_VERSION })
|
|
76
76
|
);
|
|
77
|
-
this.syncRulesContent =
|
|
78
|
-
this.storage = this.factory.getInstance(
|
|
77
|
+
this.syncRulesContent = replicationStream.syncConfigContent[0];
|
|
78
|
+
this.storage = this.factory.getInstance(replicationStream);
|
|
79
79
|
return this.storage!;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
async loadNextSyncRules() {
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
83
|
+
const syncConfig = await this.factory.getDeployingSyncConfig();
|
|
84
|
+
if (syncConfig == null) {
|
|
85
85
|
throw new Error(`Next replication stream not available`);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
this.syncRulesContent =
|
|
89
|
-
this.storage =
|
|
88
|
+
this.syncRulesContent = syncConfig.content;
|
|
89
|
+
this.storage = syncConfig.storage;
|
|
90
90
|
return this.storage!;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
async loadActiveSyncRules() {
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
94
|
+
const syncConfig = await this.factory.getActiveSyncConfig();
|
|
95
|
+
if (syncConfig == null) {
|
|
96
96
|
throw new Error(`Active replication stream not available`);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
this.syncRulesContent =
|
|
100
|
-
this.storage =
|
|
99
|
+
this.syncRulesContent = syncConfig.content;
|
|
100
|
+
this.storage = syncConfig.storage;
|
|
101
101
|
this.replicationDone = true;
|
|
102
102
|
return this.storage!;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
private
|
|
105
|
+
private getSyncConfigContent(): storage.PersistedSyncConfigContent {
|
|
106
106
|
if (this.syncRulesContent == null) {
|
|
107
107
|
throw new Error('Sync config not configured - call updateSyncRules() first');
|
|
108
108
|
}
|
|
@@ -148,7 +148,7 @@ export class BinlogStreamTestContext {
|
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
async getCheckpoint(options?: { timeout?: number }): Promise<
|
|
151
|
+
async getCheckpoint(options?: { timeout?: number }): Promise<ReplicationCheckpoint> {
|
|
152
152
|
const connection = await this.connectionManager.getConnection();
|
|
153
153
|
let checkpoint = await Promise.race([
|
|
154
154
|
getClientCheckpoint(connection, this.factory, { timeout: options?.timeout ?? 60_000 }),
|
|
@@ -165,9 +165,9 @@ export class BinlogStreamTestContext {
|
|
|
165
165
|
|
|
166
166
|
async getBucketsDataBatch(buckets: Record<string, InternalOpId>, options?: { timeout?: number }) {
|
|
167
167
|
const checkpoint = await this.getCheckpoint(options);
|
|
168
|
-
const
|
|
169
|
-
const map = Object.entries(buckets).map(([bucket, start]) => bucketRequest(
|
|
170
|
-
return test_utils.
|
|
168
|
+
const syncConfigContent = this.getSyncConfigContent();
|
|
169
|
+
const map = Object.entries(buckets).map(([bucket, start]) => bucketRequest(syncConfigContent, bucket, start));
|
|
170
|
+
return test_utils.getBatchArray(this.storage!.getBucketDataBatch(checkpoint, map));
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
async getBucketData(
|
|
@@ -179,11 +179,11 @@ export class BinlogStreamTestContext {
|
|
|
179
179
|
if (typeof start == 'string') {
|
|
180
180
|
start = BigInt(start);
|
|
181
181
|
}
|
|
182
|
-
const
|
|
182
|
+
const syncConfigContent = this.getSyncConfigContent();
|
|
183
183
|
const checkpoint = await this.getCheckpoint(options);
|
|
184
|
-
const map = [bucketRequest(
|
|
184
|
+
const map = [bucketRequest(syncConfigContent, bucket, start)];
|
|
185
185
|
const batch = this.storage!.getBucketDataBatch(checkpoint, map);
|
|
186
|
-
const batches = await test_utils.
|
|
186
|
+
const batches = await test_utils.getBatchArray(batch);
|
|
187
187
|
return batches[0]?.chunkData.data ?? [];
|
|
188
188
|
}
|
|
189
189
|
}
|
|
@@ -192,7 +192,7 @@ export async function getClientCheckpoint(
|
|
|
192
192
|
connection: mysqlPromise.Connection,
|
|
193
193
|
storageFactory: BucketStorageFactory,
|
|
194
194
|
options?: { timeout?: number }
|
|
195
|
-
): Promise<
|
|
195
|
+
): Promise<ReplicationCheckpoint> {
|
|
196
196
|
const start = Date.now();
|
|
197
197
|
const gtid = await readExecutedGtid(connection);
|
|
198
198
|
// This old API needs a persisted checkpoint id.
|
|
@@ -203,14 +203,14 @@ export async function getClientCheckpoint(
|
|
|
203
203
|
|
|
204
204
|
logger.info('Expected Checkpoint: ' + gtid.comparable);
|
|
205
205
|
while (Date.now() - start < timeout) {
|
|
206
|
-
const storage = await storageFactory.
|
|
206
|
+
const storage = (await storageFactory.getActiveSyncConfig())?.storage;
|
|
207
207
|
const cp = await storage?.getCheckpoint();
|
|
208
208
|
if (cp == null) {
|
|
209
209
|
throw new Error('No replication stream available');
|
|
210
210
|
}
|
|
211
211
|
lastCp = cp;
|
|
212
212
|
if (cp.lsn && cp.lsn >= gtid.comparable) {
|
|
213
|
-
return cp
|
|
213
|
+
return cp;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
await new Promise((resolve) => setTimeout(resolve, 30));
|
package/tsconfig.json
CHANGED