@powersync/service-module-postgres 0.0.0-dev-20240930091342 → 0.0.0-dev-20241001150444
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 +6 -7
- package/dist/api/PostgresRouteAPIAdapter.js +0 -2
- package/dist/api/PostgresRouteAPIAdapter.js.map +1 -1
- package/dist/auth/SupabaseKeyCollector.js.map +1 -1
- package/dist/module/PostgresModule.js.map +1 -1
- package/dist/replication/ConnectionManagerFactory.js.map +1 -1
- package/dist/replication/PgManager.js.map +1 -1
- package/dist/replication/PgRelation.js.map +1 -1
- package/dist/replication/PostgresErrorRateLimiter.d.ts +1 -0
- package/dist/replication/PostgresErrorRateLimiter.js.map +1 -1
- package/dist/replication/WalStream.d.ts +1 -0
- package/dist/replication/WalStream.js.map +1 -1
- package/dist/replication/WalStreamReplicationJob.js.map +1 -1
- package/dist/replication/WalStreamReplicator.js.map +1 -1
- package/dist/replication/replication-utils.js.map +1 -1
- package/dist/types/types.js.map +1 -1
- package/dist/utils/migration_lib.js.map +1 -1
- package/dist/utils/pgwire_utils.js.map +1 -1
- package/dist/utils/populate_test_data.js +41 -2
- package/dist/utils/populate_test_data.js.map +1 -1
- package/package.json +9 -9
- package/src/api/PostgresRouteAPIAdapter.ts +2 -4
- package/src/replication/PgManager.ts +1 -4
- package/src/replication/PgRelation.ts +1 -1
- package/src/utils/populate_test_data.ts +42 -2
- package/test/src/wal_stream_utils.ts +1 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.ts +1 -7
- package/dist/utils/populate_test_data_worker.d.ts +0 -1
- package/dist/utils/populate_test_data_worker.js +0 -46
- package/dist/utils/populate_test_data_worker.js.map +0 -1
- package/src/utils/populate_test_data_worker.ts +0 -50
package/vitest.config.ts
CHANGED
|
@@ -4,12 +4,6 @@ import tsconfigPaths from 'vite-tsconfig-paths';
|
|
|
4
4
|
export default defineConfig({
|
|
5
5
|
plugins: [tsconfigPaths()],
|
|
6
6
|
test: {
|
|
7
|
-
setupFiles: './test/src/setup.ts'
|
|
8
|
-
poolOptions: {
|
|
9
|
-
threads: {
|
|
10
|
-
singleThread: true
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
pool: 'threads'
|
|
7
|
+
setupFiles: './test/src/setup.ts'
|
|
14
8
|
}
|
|
15
9
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'crypto';
|
|
2
|
-
import { isMainThread, parentPort, workerData } from 'node:worker_threads';
|
|
3
|
-
import * as pgwire from '@powersync/service-jpgwire';
|
|
4
|
-
// This util is actually for tests only, but we need it compiled to JS for the service to work, so it's placed in the service.
|
|
5
|
-
if (isMainThread || parentPort == null) {
|
|
6
|
-
// Must not be imported - only expected to run in a worker
|
|
7
|
-
throw new Error('Do not import this file');
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
try {
|
|
11
|
-
const options = workerData;
|
|
12
|
-
if (options == null) {
|
|
13
|
-
throw new Error('loaded worker without options');
|
|
14
|
-
}
|
|
15
|
-
const result = await populateDataInner(options);
|
|
16
|
-
parentPort.postMessage(result);
|
|
17
|
-
process.exit(0);
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
// This is a bug, not a connection issue
|
|
21
|
-
console.error(e);
|
|
22
|
-
// Only closes the Worker thread
|
|
23
|
-
process.exit(2);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async function populateDataInner(options) {
|
|
27
|
-
// Dedicated connection so we can release the memory easily
|
|
28
|
-
const initialDb = await pgwire.connectPgWire(options.connection, { type: 'standard' });
|
|
29
|
-
const largeDescription = crypto.randomBytes(options.size / 2).toString('hex');
|
|
30
|
-
let operation_count = 0;
|
|
31
|
-
for (let i = 0; i < options.num_transactions; i++) {
|
|
32
|
-
const prefix = `test${i}K`;
|
|
33
|
-
await initialDb.query({
|
|
34
|
-
statement: `INSERT INTO test_data(id, description, other) SELECT $1 || i, $2, 'foo' FROM generate_series(1, $3) i`,
|
|
35
|
-
params: [
|
|
36
|
-
{ type: 'varchar', value: prefix },
|
|
37
|
-
{ type: 'varchar', value: largeDescription },
|
|
38
|
-
{ type: 'int4', value: options.per_transaction }
|
|
39
|
-
]
|
|
40
|
-
});
|
|
41
|
-
operation_count += options.per_transaction;
|
|
42
|
-
}
|
|
43
|
-
await initialDb.end();
|
|
44
|
-
return operation_count;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=populate_test_data_worker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"populate_test_data_worker.js","sourceRoot":"","sources":["../../src/utils/populate_test_data_worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AAGrD,8HAA8H;AAE9H,IAAI,YAAY,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;IACvC,0DAA0D;IAC1D,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC7C,CAAC;KAAM,CAAC;IACN,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,UAAiC,CAAC;QAClD,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAChD,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,wCAAwC;QACxC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,gCAAgC;QAChC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,OAA4B;IAC3D,2DAA2D;IAC3D,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IACvF,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9E,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;QAE3B,MAAM,SAAS,CAAC,KAAK,CAAC;YACpB,SAAS,EAAE,uGAAuG;YAClH,MAAM,EAAE;gBACN,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;gBAClC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE;gBAC5C,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,eAAe,EAAE;aACjD;SACF,CAAC,CAAC;QACH,eAAe,IAAI,OAAO,CAAC,eAAe,CAAC;IAC7C,CAAC;IACD,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC;IACtB,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'crypto';
|
|
2
|
-
import { isMainThread, parentPort, workerData } from 'node:worker_threads';
|
|
3
|
-
|
|
4
|
-
import * as pgwire from '@powersync/service-jpgwire';
|
|
5
|
-
import type { PopulateDataOptions } from './populate_test_data.js';
|
|
6
|
-
|
|
7
|
-
// This util is actually for tests only, but we need it compiled to JS for the service to work, so it's placed in the service.
|
|
8
|
-
|
|
9
|
-
if (isMainThread || parentPort == null) {
|
|
10
|
-
// Must not be imported - only expected to run in a worker
|
|
11
|
-
throw new Error('Do not import this file');
|
|
12
|
-
} else {
|
|
13
|
-
try {
|
|
14
|
-
const options = workerData as PopulateDataOptions;
|
|
15
|
-
if (options == null) {
|
|
16
|
-
throw new Error('loaded worker without options');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const result = await populateDataInner(options);
|
|
20
|
-
parentPort.postMessage(result);
|
|
21
|
-
process.exit(0);
|
|
22
|
-
} catch (e) {
|
|
23
|
-
// This is a bug, not a connection issue
|
|
24
|
-
console.error(e);
|
|
25
|
-
// Only closes the Worker thread
|
|
26
|
-
process.exit(2);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function populateDataInner(options: PopulateDataOptions) {
|
|
31
|
-
// Dedicated connection so we can release the memory easily
|
|
32
|
-
const initialDb = await pgwire.connectPgWire(options.connection, { type: 'standard' });
|
|
33
|
-
const largeDescription = crypto.randomBytes(options.size / 2).toString('hex');
|
|
34
|
-
let operation_count = 0;
|
|
35
|
-
for (let i = 0; i < options.num_transactions; i++) {
|
|
36
|
-
const prefix = `test${i}K`;
|
|
37
|
-
|
|
38
|
-
await initialDb.query({
|
|
39
|
-
statement: `INSERT INTO test_data(id, description, other) SELECT $1 || i, $2, 'foo' FROM generate_series(1, $3) i`,
|
|
40
|
-
params: [
|
|
41
|
-
{ type: 'varchar', value: prefix },
|
|
42
|
-
{ type: 'varchar', value: largeDescription },
|
|
43
|
-
{ type: 'int4', value: options.per_transaction }
|
|
44
|
-
]
|
|
45
|
-
});
|
|
46
|
-
operation_count += options.per_transaction;
|
|
47
|
-
}
|
|
48
|
-
await initialDb.end();
|
|
49
|
-
return operation_count;
|
|
50
|
-
}
|