@powersync/service-module-postgres 0.8.1 → 0.9.0
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 +22 -0
- package/dist/types/types.d.ts +3 -0
- package/package.json +8 -8
- package/test/src/slow_tests.test.ts +2 -2
- package/test/src/util.ts +2 -2
- package/test/src/wal_stream_utils.ts +24 -12
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @powersync/service-module-postgres
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 698467c: Use bigint everywhere internally for OpId.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [0298720]
|
|
12
|
+
- Updated dependencies [698467c]
|
|
13
|
+
- Updated dependencies [ba7baeb]
|
|
14
|
+
- @powersync/service-sync-rules@0.24.1
|
|
15
|
+
- @powersync/service-core@1.8.0
|
|
16
|
+
- @powersync/lib-service-postgres@0.4.0
|
|
17
|
+
- @powersync/service-types@0.9.0
|
|
18
|
+
|
|
19
|
+
## 0.8.2
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- @powersync/service-core@1.7.2
|
|
24
|
+
|
|
3
25
|
## 0.8.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/types/types.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const PostgresConnectionConfig: t.Intersection<t.Codec<{
|
|
|
27
27
|
tls_servername?: string | undefined;
|
|
28
28
|
reject_ip_ranges?: string[] | undefined;
|
|
29
29
|
slot_name_prefix?: string | undefined;
|
|
30
|
+
max_pool_size?: number | undefined;
|
|
30
31
|
}, {
|
|
31
32
|
type: string;
|
|
32
33
|
id?: string | undefined;
|
|
@@ -49,6 +50,7 @@ export declare const PostgresConnectionConfig: t.Intersection<t.Codec<{
|
|
|
49
50
|
tls_servername?: string | undefined;
|
|
50
51
|
reject_ip_ranges?: string[] | undefined;
|
|
51
52
|
slot_name_prefix?: string | undefined;
|
|
53
|
+
max_pool_size?: number | undefined;
|
|
52
54
|
}, string, t.CodecProps>, t.ObjectCodec<{}>>;
|
|
53
55
|
/**
|
|
54
56
|
* Config input specified when starting services
|
|
@@ -78,4 +80,5 @@ export declare function normalizeConnectionConfig(options: PostgresConnectionCon
|
|
|
78
80
|
lookup: import("net").LookupFunction | undefined;
|
|
79
81
|
client_certificate: string | undefined;
|
|
80
82
|
client_private_key: string | undefined;
|
|
83
|
+
max_pool_size: number;
|
|
81
84
|
};
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.9.0",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"license": "FSL-1.1-Apache-2.0",
|
|
11
11
|
"type": "module",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"ts-codec": "^1.3.0",
|
|
29
29
|
"uri-js": "^4.4.1",
|
|
30
30
|
"uuid": "^9.0.1",
|
|
31
|
-
"@powersync/lib-service-postgres": "0.
|
|
31
|
+
"@powersync/lib-service-postgres": "0.4.0",
|
|
32
32
|
"@powersync/lib-services-framework": "0.5.3",
|
|
33
|
-
"@powersync/service-core": "1.
|
|
33
|
+
"@powersync/service-core": "1.8.0",
|
|
34
34
|
"@powersync/service-jpgwire": "0.19.0",
|
|
35
35
|
"@powersync/service-jsonbig": "0.17.10",
|
|
36
|
-
"@powersync/service-sync-rules": "0.24.
|
|
37
|
-
"@powersync/service-types": "0.
|
|
36
|
+
"@powersync/service-sync-rules": "0.24.1",
|
|
37
|
+
"@powersync/service-types": "0.9.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/semver": "^7.5.4",
|
|
41
41
|
"@types/uuid": "^9.0.4",
|
|
42
|
-
"@powersync/service-core-tests": "0.
|
|
43
|
-
"@powersync/service-module-mongodb-storage": "0.
|
|
44
|
-
"@powersync/service-module-postgres-storage": "0.
|
|
42
|
+
"@powersync/service-core-tests": "0.7.0",
|
|
43
|
+
"@powersync/service-module-mongodb-storage": "0.7.0",
|
|
44
|
+
"@powersync/service-module-postgres-storage": "0.5.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsc -b",
|
|
@@ -178,7 +178,7 @@ bucket_definitions:
|
|
|
178
178
|
break;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
const checkpoint =
|
|
181
|
+
const checkpoint = (await storage.getCheckpoint()).checkpoint;
|
|
182
182
|
if (f instanceof mongo_storage.storage.MongoBucketStorage) {
|
|
183
183
|
const opsBefore = (await f.db.bucket_data.find().sort({ _id: 1 }).toArray())
|
|
184
184
|
.filter((row) => row._id.o <= checkpoint)
|
|
@@ -403,7 +403,7 @@ bucket_definitions:
|
|
|
403
403
|
getClientCheckpoint(pool, storage.factory, { timeout: TIMEOUT_MARGIN_MS }),
|
|
404
404
|
streamPromise
|
|
405
405
|
]);
|
|
406
|
-
if (
|
|
406
|
+
if (checkpoint == null) {
|
|
407
407
|
// This indicates an issue with the test setup - streamingPromise completed instead
|
|
408
408
|
// of getClientCheckpoint()
|
|
409
409
|
throw new Error('Test failure - streamingPromise completed');
|
package/test/src/util.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { PostgresRouteAPIAdapter } from '@module/api/PostgresRouteAPIAdapter.js'
|
|
|
2
2
|
import * as types from '@module/types/types.js';
|
|
3
3
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
4
4
|
import { logger } from '@powersync/lib-services-framework';
|
|
5
|
-
import { BucketStorageFactory,
|
|
5
|
+
import { BucketStorageFactory, InternalOpId, TestStorageOptions } from '@powersync/service-core';
|
|
6
6
|
import * as pgwire from '@powersync/service-jpgwire';
|
|
7
7
|
import * as mongo_storage from '@powersync/service-module-mongodb-storage';
|
|
8
8
|
import * as postgres_storage from '@powersync/service-module-postgres-storage';
|
|
@@ -64,7 +64,7 @@ export async function getClientCheckpoint(
|
|
|
64
64
|
db: pgwire.PgClient,
|
|
65
65
|
storageFactory: BucketStorageFactory,
|
|
66
66
|
options?: { timeout?: number }
|
|
67
|
-
): Promise<
|
|
67
|
+
): Promise<InternalOpId> {
|
|
68
68
|
const start = Date.now();
|
|
69
69
|
|
|
70
70
|
const api = new PostgresRouteAPIAdapter(db);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { PgManager } from '@module/replication/PgManager.js';
|
|
2
2
|
import { PUBLICATION_NAME, WalStream, WalStreamOptions } from '@module/replication/WalStream.js';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
BucketStorageFactory,
|
|
5
|
+
InternalOpId,
|
|
6
|
+
OplogEntry,
|
|
7
|
+
storage,
|
|
8
|
+
SyncRulesBucketStorage
|
|
9
|
+
} from '@powersync/service-core';
|
|
4
10
|
import { test_utils } from '@powersync/service-core-tests';
|
|
5
11
|
import * as pgwire from '@powersync/service-jpgwire';
|
|
6
12
|
import { clearTestDb, getClientCheckpoint, TEST_CONNECTION_OPTIONS } from './util.js';
|
|
@@ -120,27 +126,30 @@ export class WalStreamTestContext implements AsyncDisposable {
|
|
|
120
126
|
getClientCheckpoint(this.pool, this.factory, { timeout: options?.timeout ?? 15_000 }),
|
|
121
127
|
this.streamPromise
|
|
122
128
|
]);
|
|
123
|
-
if (
|
|
129
|
+
if (checkpoint == null) {
|
|
124
130
|
// This indicates an issue with the test setup - streamingPromise completed instead
|
|
125
131
|
// of getClientCheckpoint()
|
|
126
132
|
throw new Error('Test failure - streamingPromise completed');
|
|
127
133
|
}
|
|
128
|
-
return checkpoint
|
|
134
|
+
return checkpoint;
|
|
129
135
|
}
|
|
130
136
|
|
|
131
|
-
async getBucketsDataBatch(buckets: Record<string,
|
|
137
|
+
async getBucketsDataBatch(buckets: Record<string, InternalOpId>, options?: { timeout?: number }) {
|
|
132
138
|
let checkpoint = await this.getCheckpoint(options);
|
|
133
|
-
const map = new Map<string,
|
|
139
|
+
const map = new Map<string, InternalOpId>(Object.entries(buckets));
|
|
134
140
|
return test_utils.fromAsync(this.storage!.getBucketDataBatch(checkpoint, map));
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
/**
|
|
138
144
|
* This waits for a client checkpoint.
|
|
139
145
|
*/
|
|
140
|
-
async getBucketData(bucket: string, start?: string, options?: { timeout?: number }) {
|
|
141
|
-
start ??=
|
|
146
|
+
async getBucketData(bucket: string, start?: InternalOpId | string | undefined, options?: { timeout?: number }) {
|
|
147
|
+
start ??= 0n;
|
|
148
|
+
if (typeof start == 'string') {
|
|
149
|
+
start = BigInt(start);
|
|
150
|
+
}
|
|
142
151
|
const checkpoint = await this.getCheckpoint(options);
|
|
143
|
-
const map = new Map<string,
|
|
152
|
+
const map = new Map<string, InternalOpId>([[bucket, start]]);
|
|
144
153
|
let data: OplogEntry[] = [];
|
|
145
154
|
while (true) {
|
|
146
155
|
const batch = this.storage!.getBucketDataBatch(checkpoint, map);
|
|
@@ -150,7 +159,7 @@ export class WalStreamTestContext implements AsyncDisposable {
|
|
|
150
159
|
if (batches.length == 0 || !batches[0]!.batch.has_more) {
|
|
151
160
|
break;
|
|
152
161
|
}
|
|
153
|
-
map.set(bucket, batches[0]!.batch.next_after);
|
|
162
|
+
map.set(bucket, BigInt(batches[0]!.batch.next_after));
|
|
154
163
|
}
|
|
155
164
|
return data;
|
|
156
165
|
}
|
|
@@ -158,10 +167,13 @@ export class WalStreamTestContext implements AsyncDisposable {
|
|
|
158
167
|
/**
|
|
159
168
|
* This does not wait for a client checkpoint.
|
|
160
169
|
*/
|
|
161
|
-
async getCurrentBucketData(bucket: string, start?: string) {
|
|
162
|
-
start ??=
|
|
170
|
+
async getCurrentBucketData(bucket: string, start?: InternalOpId | string | undefined) {
|
|
171
|
+
start ??= 0n;
|
|
172
|
+
if (typeof start == 'string') {
|
|
173
|
+
start = BigInt(start);
|
|
174
|
+
}
|
|
163
175
|
const { checkpoint } = await this.storage!.getCheckpoint();
|
|
164
|
-
const map = new Map<string,
|
|
176
|
+
const map = new Map<string, InternalOpId>([[bucket, start]]);
|
|
165
177
|
const batch = this.storage!.getBucketDataBatch(checkpoint, map);
|
|
166
178
|
const batches = await test_utils.fromAsync(batch);
|
|
167
179
|
return batches[0]?.batch.data ?? [];
|