@m2k-5f/pgtx 2.6.0 → 2.6.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/README.md +65 -81
- package/dist/batch.d.ts +1 -1
- package/dist/batch.d.ts.map +1 -1
- package/dist/batch.js +1 -2
- package/dist/clauses/abstract.clause.d.ts.map +1 -1
- package/dist/connection.d.ts +4 -26
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +40 -36
- package/dist/error.d.ts +5 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/pool.d.ts +7 -12
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +22 -23
- package/dist/protocol/connection-response-reader.d.ts +2 -4
- package/dist/protocol/connection-response-reader.d.ts.map +1 -1
- package/dist/protocol/connection-response-reader.js +1 -2
- package/dist/protocol/socket-authorization.d.ts +1 -10
- package/dist/protocol/socket-authorization.d.ts.map +1 -1
- package/dist/protocol/socket-authorization.js +1 -4
- package/dist/protocol/socket-connector.d.ts.map +1 -1
- package/dist/protocol/socket-connector.js +0 -2
- package/dist/query.d.ts +5 -14
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +7 -15
- package/dist/transaction.d.ts +2 -3
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +13 -11
- package/dist/types.d.ts +52 -11
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,83 +64,65 @@
|
|
|
64
64
|
- **Connection pool** — Auto-management connections with support for pipeline queries via the pool itself.
|
|
65
65
|
- **Zero dependencies** — Lightweight and blazing
|
|
66
66
|
|
|
67
|
-
---
|
|
67
|
+
---
|
|
68
68
|
|
|
69
|
-
## ⚡ Performance
|
|
69
|
+
## ⚡ Performance
|
|
70
70
|
|
|
71
|
-
All benchmarks are executed on **GitHub Actions** (Ubuntu, 2 vCPUs) and are fully reproducible. Benchmark sources are included in this repository.
|
|
71
|
+
All benchmarks are executed on **GitHub Actions** (Ubuntu, 2 vCPUs) and are fully reproducible. Benchmark sources are included in this repository.
|
|
72
72
|
|
|
73
|
-
### 1. PostgreSQL Pipeline Stress Test
|
|
73
|
+
### 1. PostgreSQL Pipeline Stress Test
|
|
74
74
|
|
|
75
|
-
**3000 concurrent parameterized `SELECT` queries**
|
|
75
|
+
**3000 concurrent parameterized `SELECT` queries**
|
|
76
76
|
|
|
77
|
-
* Connection pool: **10 connections**
|
|
78
|
-
* Measured with **mitata**
|
|
77
|
+
* Connection pool: **10 connections**
|
|
78
|
+
* Measured with **mitata**
|
|
79
79
|
|
|
80
|
-
| Driver | Avg Time | Relative Speed | Memory (p75) |
|
|
81
|
-
| :--------------------- | -----------: | -------------------: | -----------: |
|
|
82
|
-
| **Pgtx (Pipeline)** | **24.18 ms** | **Baseline (1.00×)** | **≈2.5 MB** |
|
|
83
|
-
| Postgres.js (Pipeline) | 83.36 ms | **3.45× slower** | ≈7.6 MB |
|
|
84
|
-
| node-postgres (`pg`) | 377.95 ms | **15.63× slower** | ≈11.4 MB |
|
|
80
|
+
| Driver | Avg Time | Relative Speed | Memory (p75) |
|
|
81
|
+
| :--------------------- | -----------: | -------------------: | -----------: |
|
|
82
|
+
| **Pgtx (Pipeline)** | **24.18 ms** | **Baseline (1.00×)** | **≈2.5 MB** |
|
|
83
|
+
| Postgres.js (Pipeline) | 83.36 ms | **3.45× slower** | ≈7.6 MB |
|
|
84
|
+
| node-postgres (`pg`) | 377.95 ms | **15.63× slower** | ≈11.4 MB |
|
|
85
85
|
|
|
86
|
-
### 2. Real-World HTTP Throughput
|
|
86
|
+
### 2. Real-World HTTP Throughput
|
|
87
87
|
|
|
88
|
-
Simple `node:http` server serving a PostgreSQL-backed endpoint.
|
|
88
|
+
Simple `node:http` server serving a PostgreSQL-backed endpoint.
|
|
89
89
|
|
|
90
|
-
Measured with:
|
|
90
|
+
Measured with:
|
|
91
91
|
|
|
92
|
-
```bash
|
|
93
|
-
wrk -t2 -c<N> -d10s http://localhost:3000/users
|
|
94
|
-
```
|
|
92
|
+
```bash
|
|
93
|
+
wrk -t2 -c<N> -d10s http://localhost:3000/users
|
|
94
|
+
```
|
|
95
95
|
|
|
96
|
-
| Concurrent Connections | Pgtx | Postgres.js | Speedup |
|
|
97
|
-
| ---------------------: | ---------------: | -----------: | --------: |
|
|
98
|
-
| 50 | 5,272 req/s | 5,691 req/s | 0.93× |
|
|
99
|
-
| 200 | **12,918 req/s** | 6,724 req/s | **1.92×** |
|
|
100
|
-
| 1000 | **21,429 req/s** | 8,423 req/s | **2.54×** |
|
|
101
|
-
| 10000 | **22,486 req/s** | 12,764 req/s | **1.76×** |
|
|
96
|
+
| Concurrent Connections | Pgtx | Postgres.js | Speedup |
|
|
97
|
+
| ---------------------: | ---------------: | -----------: | --------: |
|
|
98
|
+
| 50 | 5,272 req/s | 5,691 req/s | 0.93× |
|
|
99
|
+
| 200 | **12,918 req/s** | 6,724 req/s | **1.92×** |
|
|
100
|
+
| 1000 | **21,429 req/s** | 8,423 req/s | **2.54×** |
|
|
101
|
+
| 10000 | **22,486 req/s** | 12,764 req/s | **1.76×** |
|
|
102
102
|
|
|
103
|
-
### Why is Pgtx fast?
|
|
103
|
+
### Why is Pgtx fast?
|
|
104
104
|
|
|
105
|
-
Pgtx is engineered for **throughput**, not for minimizing the latency of individual queries.
|
|
105
|
+
Pgtx is engineered for **throughput**, not for minimizing the latency of individual queries.
|
|
106
106
|
|
|
107
|
-
Instead of optimizing a single request in isolation, Pgtx minimizes per-query overhead under sustained concurrent load by combining:
|
|
107
|
+
Instead of optimizing a single request in isolation, Pgtx minimizes per-query overhead under sustained concurrent load by combining:
|
|
108
108
|
|
|
109
|
-
* Pipeline query multiplexing
|
|
110
|
-
* Synchronous PostgreSQL wire protocol encoding
|
|
111
|
-
* Batched socket writes
|
|
112
|
-
* Automatic prepared statement caching
|
|
113
|
-
* Prepared statement deduplication
|
|
114
|
-
* Row description caching
|
|
115
|
-
* Binary protocol support
|
|
116
|
-
* Zero-dependency implementation
|
|
109
|
+
* Pipeline query multiplexing
|
|
110
|
+
* Synchronous PostgreSQL wire protocol encoding
|
|
111
|
+
* Batched socket writes
|
|
112
|
+
* Automatic prepared statement caching
|
|
113
|
+
* Prepared statement deduplication
|
|
114
|
+
* Row description caching
|
|
115
|
+
* Binary protocol support
|
|
116
|
+
* Zero-dependency implementation
|
|
117
117
|
|
|
118
|
-
As concurrency increases, these optimizations significantly reduce protocol overhead, allowing Pgtx to scale more efficiently than traditional PostgreSQL drivers.
|
|
118
|
+
As concurrency increases, these optimizations significantly reduce protocol overhead, allowing Pgtx to scale more efficiently than traditional PostgreSQL drivers.
|
|
119
119
|
|
|
120
|
-
In the `mitata` benchmark, Pgtx also demonstrated approximately **
|
|
120
|
+
In the `mitata` benchmark, Pgtx also demonstrated approximately **2× lower memory usage** than Postgres.js while processing the same workload, reducing allocation pressure and improving sustained throughput under heavy load.
|
|
121
121
|
|
|
122
|
-
> **Blazing** isn't just a tagline — it's backed by reproducible benchmarks.
|
|
122
|
+
> **Blazing** isn't just a tagline — it's backed by reproducible benchmarks.
|
|
123
123
|
|
|
124
124
|
---
|
|
125
125
|
|
|
126
|
-
## 🔥 Why Pgtx?
|
|
127
|
-
|
|
128
|
-
| Capability | **Pgtx** | **Postgres.js** | **pg** |
|
|
129
|
-
| -------------------------------- | :------: | :-------------: | :----: |
|
|
130
|
-
| Pipeline queries | ✅ | ✅ | ❌ |
|
|
131
|
-
| Pipeline multiplexing in pool | ✅ | ❌ | ❌ |
|
|
132
|
-
| Tagged template SQL | ✅ | ✅ | ❌ |
|
|
133
|
-
| Automatic prepared statements | ✅ | ✅ | ✅ |
|
|
134
|
-
| Prepared statement deduplication | ✅ | ❌ | ❌ |
|
|
135
|
-
| Transactions | ✅ | ✅ | ✅ |
|
|
136
|
-
| Savepoints | ✅ | ✅ | ❌ |
|
|
137
|
-
| LISTEN / NOTIFY | ✅ | ✅ | ✅ |
|
|
138
|
-
| Connection pool | ✅ | ✅ | ✅ |
|
|
139
|
-
| Zero dependencies | ✅ | ✅ | ❌ |
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
|
|
144
126
|
## 📖 Features
|
|
145
127
|
|
|
146
128
|
### 🎯 Typed Error Handling
|
|
@@ -167,9 +149,9 @@ In the `mitata` benchmark, Pgtx also demonstrated approximately **3× lower memo
|
|
|
167
149
|
```typescript
|
|
168
150
|
// 5 queries, only 2 network round-trips
|
|
169
151
|
const {user, posts, ...data} = await Bind({
|
|
170
|
-
user:
|
|
171
|
-
config:
|
|
172
|
-
announcements:
|
|
152
|
+
user: pool.query<User>`...`,
|
|
153
|
+
config: pool.query<Config>`...`,
|
|
154
|
+
announcements: pool.query<Announcement>`...`
|
|
173
155
|
})
|
|
174
156
|
.bind({
|
|
175
157
|
posts: ({ user }) => pool.query<Post>`...`,
|
|
@@ -452,26 +434,28 @@ In the `mitata` benchmark, Pgtx also demonstrated approximately **3× lower memo
|
|
|
452
434
|
### Connection
|
|
453
435
|
```typescript
|
|
454
436
|
class Connection {
|
|
455
|
-
static new(params:
|
|
437
|
+
static new(params: ConnectionPartialParams): Promise<Connection>
|
|
456
438
|
|
|
457
439
|
query<T>(strings: TemplateStringsArray, ...values: any[]): Future<T[], PostgresError>
|
|
458
|
-
begin<T>(callback: (tx: Transaction) => Promise<T>): Future<T,
|
|
459
|
-
notify(channelName: string, payload?: string): Future<
|
|
460
|
-
listen(channelName: string, callback: (payload: string) => void): Future<
|
|
461
|
-
unlisten(channelName: string, callback: (payload: string) => void): Future<
|
|
440
|
+
begin<T>(callback: (tx: Transaction) => Promise<T>): Future<T, unknown>
|
|
441
|
+
notify(channelName: string, payload?: string): Future<void, PostgresError>
|
|
442
|
+
listen(channelName: string, callback: (payload: string) => void): Future<void, PostgresError>
|
|
443
|
+
unlisten(channelName: string, callback: (payload: string) => void): Future<void, PostgresError>
|
|
462
444
|
stream<T extends Record<string, any>>(templates: TemplateStringsArray, ...params: any[]): ReadableStream<T>
|
|
463
445
|
get isAlive(): boolean
|
|
464
446
|
close(): void
|
|
465
447
|
}
|
|
466
448
|
|
|
467
|
-
interface
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
449
|
+
interface ConnectionPartialParams {
|
|
450
|
+
user: string
|
|
451
|
+
password?: string
|
|
452
|
+
host: string
|
|
453
|
+
port: number
|
|
454
|
+
database: string
|
|
455
|
+
logLevel?: LogLevel, // default "error"
|
|
456
|
+
int8toBigint?: boolean, // default false
|
|
457
|
+
queryTimeout?: number // default 30000 (30 seconds)
|
|
458
|
+
syncShedule?: "Tick" | "Immediate" // default "Immediate"
|
|
475
459
|
}
|
|
476
460
|
```
|
|
477
461
|
|
|
@@ -479,14 +463,14 @@ In the `mitata` benchmark, Pgtx also demonstrated approximately **3× lower memo
|
|
|
479
463
|
|
|
480
464
|
```typescript
|
|
481
465
|
class Pool {
|
|
482
|
-
constructor(config:
|
|
466
|
+
constructor(config: PoolPartialConfig)
|
|
483
467
|
|
|
484
468
|
query<T>(strings: TemplateStringsArray, ...values: any[]): Future<T[], PostgresError>
|
|
485
|
-
begin<T>(callback: (tx: Transaction) => Promise<T>): Future<T,
|
|
486
|
-
notify(channelName: string, payload?: string): Future<
|
|
487
|
-
listen(channel: string, callback: (payload: string) => void): Future<() =>
|
|
469
|
+
begin<T>(callback: (tx: Transaction) => Promise<T>): Future<T, unknown>
|
|
470
|
+
notify(channelName: string, payload?: string): Future<void, PostgresError>
|
|
471
|
+
listen(channel: string, callback: (payload: string) => void): Future<() => Future<void, PostgresError>, PostgresError>
|
|
488
472
|
stream<T extends Record<string, any>>(templates: TemplateStringsArray, ...args: any[]): ReadableStream<T>
|
|
489
|
-
withAcquire<T>(fn: (conn: Connection) => Promise<T>): Future<T,
|
|
473
|
+
withAcquire<T>(fn: (conn: Connection) => Promise<T>): Future<T, unknown>
|
|
490
474
|
acquire(): Future<Connection, PostgresError>
|
|
491
475
|
release(conn: Connection): void
|
|
492
476
|
close(): void
|
|
@@ -495,7 +479,7 @@ In the `mitata` benchmark, Pgtx also demonstrated approximately **3× lower memo
|
|
|
495
479
|
get total(): number
|
|
496
480
|
}
|
|
497
481
|
|
|
498
|
-
interface
|
|
482
|
+
interface PoolPartialConfig extends ConnectionPartialConfig {
|
|
499
483
|
max?: number
|
|
500
484
|
}
|
|
501
485
|
```
|
|
@@ -505,9 +489,9 @@ In the `mitata` benchmark, Pgtx also demonstrated approximately **3× lower memo
|
|
|
505
489
|
```typescript
|
|
506
490
|
class Transaction {
|
|
507
491
|
query<T>(strings: TemplateStringsArray, ...values: any[]): Future<T[], PostgresError>
|
|
508
|
-
commit(): Future<
|
|
509
|
-
rollback(): Future<
|
|
510
|
-
savepoint<T>(name: string, callback: (tx: Transaction) => Promise<T>): Future<T,
|
|
492
|
+
commit(): Future<void, PostgresError>
|
|
493
|
+
rollback(): Future<void, PostgresError>
|
|
494
|
+
savepoint<T>(name: string, callback: (tx: Transaction) => Promise<T>): Future<T, unknown>
|
|
511
495
|
|
|
512
496
|
get isActive(): boolean
|
|
513
497
|
}
|
package/dist/batch.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class Batch {
|
|
|
5
5
|
private _queryQueue;
|
|
6
6
|
private _buffer;
|
|
7
7
|
constructor(buffer: ConnectionRequestWriter);
|
|
8
|
-
registerQuery(query: PostgresQuery
|
|
8
|
+
registerQuery(query: PostgresQuery): void;
|
|
9
9
|
end(): ConnectionRequestWriter;
|
|
10
10
|
get current(): PostgresQuery;
|
|
11
11
|
next(): void;
|
package/dist/batch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAc,aAAa,EAAE,MAAM,SAAS,CAAC;AAGpD,qBAAa,KAAK;IACd,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,OAAO,CAAyB;gBAE5B,MAAM,EAAE,uBAAuB;IAK3C,aAAa,CAAC,KAAK,EAAE,aAAa;IAelC,GAAG;IAIH,IAAI,OAAO,kBAEV;IAED,IAAI;IAIJ,MAAM,CAAC,KAAK,EAAE,aAAa;CAK9B"}
|
package/dist/batch.js
CHANGED
|
@@ -5,9 +5,8 @@ export class Batch {
|
|
|
5
5
|
this._queryQueue = new Queue();
|
|
6
6
|
this._buffer = buffer;
|
|
7
7
|
}
|
|
8
|
-
registerQuery(query
|
|
8
|
+
registerQuery(query) {
|
|
9
9
|
this._queryQueue.push(query);
|
|
10
|
-
query.startTimeout(timeout);
|
|
11
10
|
if (query instanceof ParseQuery) {
|
|
12
11
|
this._buffer
|
|
13
12
|
.writeParse(query.statement, query.text)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.clause.d.ts","sourceRoot":"","sources":["../../src/clauses/abstract.clause.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"abstract.clause.d.ts","sourceRoot":"","sources":["../../src/clauses/abstract.clause.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,8BAAsB,MAAM;IACxB,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;CAC5D"}
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConnectionPartialConfig } from "./types";
|
|
2
2
|
import { Transaction } from "./transaction";
|
|
3
3
|
import { Future } from 'fluent-future';
|
|
4
4
|
import { PostgresError } from "./error";
|
|
5
|
-
type LogLevel = "none" | "error" | "notice" | "query";
|
|
6
|
-
export type ConnectionParams = {
|
|
7
|
-
user: string;
|
|
8
|
-
password?: string;
|
|
9
|
-
host: string;
|
|
10
|
-
port: number;
|
|
11
|
-
database: string;
|
|
12
|
-
logLevel?: LogLevel;
|
|
13
|
-
int8toBigint?: boolean;
|
|
14
|
-
queryTimeout?: number;
|
|
15
|
-
batchCapacity?: number;
|
|
16
|
-
flushShedule?: "nextTick" | "Immediate";
|
|
17
|
-
};
|
|
18
|
-
export type StatementName = Branded<string, 'StatementName'>;
|
|
19
|
-
export type QueryText = Branded<string, 'QueryText'>;
|
|
20
|
-
export type ChannelName = Branded<string, "ChannelName">;
|
|
21
|
-
export type QueryMeta = {
|
|
22
|
-
statement: StatementName;
|
|
23
|
-
columns: ColumnDescription[];
|
|
24
|
-
};
|
|
25
5
|
/**
|
|
26
6
|
* Represents a single dedicated connection to the PostgreSQL database.
|
|
27
7
|
*
|
|
@@ -53,7 +33,7 @@ export type QueryMeta = {
|
|
|
53
33
|
* ```
|
|
54
34
|
*/
|
|
55
35
|
export declare class Connection {
|
|
56
|
-
private readonly
|
|
36
|
+
private readonly config;
|
|
57
37
|
private _activeBatch;
|
|
58
38
|
private _isOpened;
|
|
59
39
|
private _isReconnecting;
|
|
@@ -64,7 +44,6 @@ export declare class Connection {
|
|
|
64
44
|
private _parsing;
|
|
65
45
|
private _listeningCallbacks;
|
|
66
46
|
private _stmtCounter;
|
|
67
|
-
private _logLevel;
|
|
68
47
|
private _nextStatement;
|
|
69
48
|
private constructor();
|
|
70
49
|
/**
|
|
@@ -85,7 +64,7 @@ export declare class Connection {
|
|
|
85
64
|
* })
|
|
86
65
|
* ```
|
|
87
66
|
*/
|
|
88
|
-
static new(
|
|
67
|
+
static new(config: ConnectionPartialConfig): Future<Connection, PostgresError>;
|
|
89
68
|
private _registerBatch;
|
|
90
69
|
private _sync;
|
|
91
70
|
/**
|
|
@@ -146,7 +125,7 @@ export declare class Connection {
|
|
|
146
125
|
* await conn.notify('events', 'hello')
|
|
147
126
|
* ```
|
|
148
127
|
*/
|
|
149
|
-
notify(channelName: string, payload?: string): Future<
|
|
128
|
+
notify(channelName: string, payload?: string): Future<void, PostgresError>;
|
|
150
129
|
/**
|
|
151
130
|
* Subscribes a callback to a channel. Sends `LISTEN` on the first subscription.
|
|
152
131
|
*
|
|
@@ -222,5 +201,4 @@ export declare class Connection {
|
|
|
222
201
|
*/
|
|
223
202
|
close(): void;
|
|
224
203
|
}
|
|
225
|
-
export {};
|
|
226
204
|
//# sourceMappingURL=connection.d.ts.map
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAMA,OAAO,EAA6D,uBAAuB,EAAuC,MAAM,SAAS,CAAA;AACjJ,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAK3C,OAAO,EAAS,MAAM,EAAM,MAAM,eAAe,CAAA;AACjD,OAAO,EAAkD,aAAa,EAAE,MAAM,SAAS,CAAA;AAKvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IAEzC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,aAAa,CAAgC;IAErD,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,WAAW,CAA4B;IAE/C,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,QAAQ,CAAyD;IAEzE,OAAO,CAAC,mBAAmB,CAAyD;IACpF,OAAO,CAAC,YAAY,CAAI;I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AOzB,OAAO,CAAC,aAAa;IAqHrB;;;OAGG;IACH,IAAI,QAAQ,YAEX;IAGD;;;;;;;;;OASG;IACH,KAAK;CAKR"}
|
package/dist/connection.js
CHANGED
|
@@ -10,6 +10,7 @@ import { sql } from ".";
|
|
|
10
10
|
import { Begin, Future, Ok } from 'fluent-future';
|
|
11
11
|
import { ErrConnectionClosed, ErrConnectionReconnecting } from "./error";
|
|
12
12
|
import { Batch } from "./batch";
|
|
13
|
+
import { nextTick } from "process";
|
|
13
14
|
/**
|
|
14
15
|
* Represents a single dedicated connection to the PostgreSQL database.
|
|
15
16
|
*
|
|
@@ -44,7 +45,7 @@ export class Connection {
|
|
|
44
45
|
_nextStatement() {
|
|
45
46
|
return `s-${this._stmtCounter++}`;
|
|
46
47
|
}
|
|
47
|
-
constructor(
|
|
48
|
+
constructor(config, socket) {
|
|
48
49
|
this._activeBatch = null;
|
|
49
50
|
this._isOpened = true;
|
|
50
51
|
this._isReconnecting = false;
|
|
@@ -54,8 +55,7 @@ export class Connection {
|
|
|
54
55
|
this._parsing = new Map();
|
|
55
56
|
this._listeningCallbacks = new Map();
|
|
56
57
|
this._stmtCounter = 0;
|
|
57
|
-
this.
|
|
58
|
-
this._logLevel = logLevel;
|
|
58
|
+
this.config = config;
|
|
59
59
|
this._socket = new SocketConnector(socket, (type, _, reader) => this._handlePacket(type, reader), () => this._registerReconnect());
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -76,16 +76,23 @@ export class Connection {
|
|
|
76
76
|
* })
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
static new(
|
|
79
|
+
static new(config) {
|
|
80
|
+
const conf = {
|
|
81
|
+
...config,
|
|
82
|
+
logLevel: config.logLevel || 'error',
|
|
83
|
+
int8toBigint: config.int8toBigint || false,
|
|
84
|
+
queryTimeout: config.queryTimeout || 30000,
|
|
85
|
+
syncShedule: config.syncShedule || 'Immediate'
|
|
86
|
+
};
|
|
80
87
|
const writer = ConnectionRequestWriter.new();
|
|
81
|
-
return createAuthorizedSocket(writer,
|
|
82
|
-
.andThen(socket => Ok(new Connection(
|
|
88
|
+
return createAuthorizedSocket(writer, conf)
|
|
89
|
+
.andThen(socket => Ok(new Connection(conf, socket)));
|
|
83
90
|
}
|
|
84
91
|
_registerBatch() {
|
|
85
92
|
if (!this._activeBatch) {
|
|
86
93
|
const batch = new Batch(this._cachedBuffer.clear());
|
|
87
94
|
this._activeBatch = batch;
|
|
88
|
-
setImmediate(() => {
|
|
95
|
+
(this.config.syncShedule === 'Immediate' ? setImmediate : nextTick)(() => {
|
|
89
96
|
this._sync(batch);
|
|
90
97
|
});
|
|
91
98
|
return batch;
|
|
@@ -143,25 +150,24 @@ export class Connection {
|
|
|
143
150
|
if (this._isReconnecting)
|
|
144
151
|
return Future.reject(ErrConnectionReconnecting);
|
|
145
152
|
const { text, args } = compileSqlTemplate(templates, params);
|
|
146
|
-
if (this.
|
|
153
|
+
if (this.config.logLevel === 'query') {
|
|
147
154
|
console.log(`\nQUERY: ${text}\n${args.length !== 0 ? `ARGUMENTS: [${args}]\n` : ""}`);
|
|
148
155
|
}
|
|
149
|
-
const batch = this._registerBatch();
|
|
150
156
|
if (this._parsed.has(text)) {
|
|
151
157
|
const meta = this._parsed.get(text);
|
|
152
|
-
const query = new SimpleQuery(meta.statement, text, args, meta.columns);
|
|
153
|
-
|
|
158
|
+
const query = new SimpleQuery(meta.statement, text, args, meta.columns, this.config.queryTimeout);
|
|
159
|
+
this._registerBatch().registerQuery(query);
|
|
154
160
|
return query.future;
|
|
155
161
|
}
|
|
156
162
|
if (!this._parsing.has(text)) {
|
|
157
|
-
const parseQuery = new ParseQuery(this._nextStatement(), text);
|
|
163
|
+
const parseQuery = new ParseQuery(this._nextStatement(), text, this.config.queryTimeout);
|
|
158
164
|
this._parsing.set(text, parseQuery.future);
|
|
159
|
-
|
|
165
|
+
this._registerBatch().registerQuery(parseQuery);
|
|
160
166
|
}
|
|
161
167
|
const future = this._parsing.get(text);
|
|
162
168
|
return future.andThen(meta => {
|
|
163
|
-
const query = new SimpleQuery(meta.statement, text, args, meta.columns);
|
|
164
|
-
this._registerBatch().registerQuery(query
|
|
169
|
+
const query = new SimpleQuery(meta.statement, text, args, meta.columns, this.config.queryTimeout);
|
|
170
|
+
this._registerBatch().registerQuery(query);
|
|
165
171
|
return query.future;
|
|
166
172
|
});
|
|
167
173
|
}
|
|
@@ -220,7 +226,7 @@ export class Connection {
|
|
|
220
226
|
return Future.reject(ErrConnectionClosed);
|
|
221
227
|
if (this._isReconnecting)
|
|
222
228
|
return Future.reject(ErrConnectionReconnecting);
|
|
223
|
-
return this.query `select pg_notify(${channelName}, ${payload})
|
|
229
|
+
return this.query `select pg_notify(${channelName}, ${payload})`.map(() => { });
|
|
224
230
|
}
|
|
225
231
|
/**
|
|
226
232
|
* Subscribes a callback to a channel. Sends `LISTEN` on the first subscription.
|
|
@@ -303,7 +309,7 @@ export class Connection {
|
|
|
303
309
|
if (this._isReconnecting)
|
|
304
310
|
throw ErrConnectionReconnecting;
|
|
305
311
|
const { text, args } = compileSqlTemplate(templates, params);
|
|
306
|
-
if (this.
|
|
312
|
+
if (this.config.logLevel === 'query') {
|
|
307
313
|
console.log(`\nQUERY: ${text}\n${args.length !== 0 ? `ARGUMENTS: [${args}]\n` : ""}`);
|
|
308
314
|
}
|
|
309
315
|
let controller;
|
|
@@ -312,23 +318,22 @@ export class Connection {
|
|
|
312
318
|
controller = c;
|
|
313
319
|
}
|
|
314
320
|
});
|
|
315
|
-
const batch = this._registerBatch();
|
|
316
321
|
if (this._parsed.has(text)) {
|
|
317
322
|
const meta = this._parsed.get(text);
|
|
318
|
-
const query = new StreamQuery(meta.statement, text, args, controller, meta.columns);
|
|
319
|
-
|
|
323
|
+
const query = new StreamQuery(meta.statement, text, args, controller, meta.columns, this.config.queryTimeout);
|
|
324
|
+
this._registerBatch().registerQuery(query);
|
|
320
325
|
return stream;
|
|
321
326
|
}
|
|
322
327
|
if (!this._parsing.has(text)) {
|
|
323
|
-
const parseQuery = new ParseQuery(this._nextStatement(), text);
|
|
328
|
+
const parseQuery = new ParseQuery(this._nextStatement(), text, this.config.queryTimeout);
|
|
324
329
|
this._parsing.set(text, parseQuery.future);
|
|
325
|
-
|
|
330
|
+
this._registerBatch().registerQuery(parseQuery);
|
|
326
331
|
}
|
|
327
332
|
const future = this._parsing.get(text);
|
|
328
333
|
future
|
|
329
334
|
.tap(meta => {
|
|
330
|
-
const query = new StreamQuery(meta.statement, text, args, controller, meta.columns);
|
|
331
|
-
this._registerBatch().registerQuery(query
|
|
335
|
+
const query = new StreamQuery(meta.statement, text, args, controller, meta.columns, this.config.queryTimeout);
|
|
336
|
+
this._registerBatch().registerQuery(query);
|
|
332
337
|
})
|
|
333
338
|
.catch(err => controller.error(err));
|
|
334
339
|
return stream;
|
|
@@ -339,25 +344,24 @@ export class Connection {
|
|
|
339
344
|
if (this._isReconnecting)
|
|
340
345
|
throw ErrConnectionReconnecting;
|
|
341
346
|
const { text, args } = compileSqlTemplate(templates, params);
|
|
342
|
-
if (this.
|
|
347
|
+
if (this.config.logLevel === 'query') {
|
|
343
348
|
console.log(`\nQUERY: ${text}\n${args.length !== 0 ? `ARGUMENTS: [${args}]\n` : ""}`);
|
|
344
349
|
}
|
|
345
|
-
const batch = this._registerBatch();
|
|
346
350
|
if (this._parsed.has(text)) {
|
|
347
351
|
const meta = this._parsed.get(text);
|
|
348
|
-
const query = new StreamQuery(meta.statement, text, args, controller, meta.columns);
|
|
349
|
-
|
|
352
|
+
const query = new StreamQuery(meta.statement, text, args, controller, meta.columns, this.config.queryTimeout);
|
|
353
|
+
this._registerBatch().registerQuery(query);
|
|
350
354
|
}
|
|
351
355
|
if (!this._parsing.has(text)) {
|
|
352
|
-
const parseQuery = new ParseQuery(this._nextStatement(), text);
|
|
356
|
+
const parseQuery = new ParseQuery(this._nextStatement(), text, this.config.queryTimeout);
|
|
353
357
|
this._parsing.set(text, parseQuery.future);
|
|
354
|
-
|
|
358
|
+
this._registerBatch().registerQuery(parseQuery);
|
|
355
359
|
}
|
|
356
360
|
const future = this._parsing.get(text);
|
|
357
361
|
future
|
|
358
362
|
.tap(meta => {
|
|
359
|
-
const query = new StreamQuery(meta.statement, text, args, controller, meta.columns);
|
|
360
|
-
this._registerBatch().registerQuery(query
|
|
363
|
+
const query = new StreamQuery(meta.statement, text, args, controller, meta.columns, this.config.queryTimeout);
|
|
364
|
+
this._registerBatch().registerQuery(query);
|
|
361
365
|
})
|
|
362
366
|
.catch(err => controller.error(err));
|
|
363
367
|
}
|
|
@@ -373,7 +377,7 @@ export class Connection {
|
|
|
373
377
|
this._rejectAllBatches(cause);
|
|
374
378
|
}
|
|
375
379
|
async _reconnect() {
|
|
376
|
-
const socket = await createAuthorizedSocket(ConnectionRequestWriter.new(), this.
|
|
380
|
+
const socket = await createAuthorizedSocket(ConnectionRequestWriter.new(), this.config);
|
|
377
381
|
const connector = new SocketConnector(socket, (type, _, reader) => this._handlePacket(type, reader), (err) => this._registerReconnect());
|
|
378
382
|
this._socket = connector;
|
|
379
383
|
this._resetConnectionState(ErrConnectionReconnecting);
|
|
@@ -441,7 +445,7 @@ export class Connection {
|
|
|
441
445
|
case ResponseTypes.DataRow:
|
|
442
446
|
{
|
|
443
447
|
let query = this._getCurrentQuery();
|
|
444
|
-
query.push(reader.readDataRow(query.columns, this.
|
|
448
|
+
query.push(reader.readDataRow(query.columns, this.config.int8toBigint));
|
|
445
449
|
}
|
|
446
450
|
break;
|
|
447
451
|
case ResponseTypes.ComandComplete:
|
|
@@ -455,7 +459,7 @@ export class Connection {
|
|
|
455
459
|
case ResponseTypes.ErrorResponse:
|
|
456
460
|
{
|
|
457
461
|
const error = reader.readErrorResponse();
|
|
458
|
-
if (this.
|
|
462
|
+
if (this.config.logLevel === 'error' || this.config.logLevel === 'notice' || this.config.logLevel === 'query') {
|
|
459
463
|
console.log(`\nError: ${error}\n`);
|
|
460
464
|
}
|
|
461
465
|
const query = this._getCurrentQuery();
|
|
@@ -472,7 +476,7 @@ export class Connection {
|
|
|
472
476
|
case ResponseTypes.Notice:
|
|
473
477
|
{
|
|
474
478
|
const message = reader.readErrorResponse();
|
|
475
|
-
if (this.
|
|
479
|
+
if (this.config.logLevel === 'notice' || this.config.logLevel === 'query') {
|
|
476
480
|
console.log(`\nError: ${message}\n`);
|
|
477
481
|
}
|
|
478
482
|
}
|
package/dist/error.d.ts
CHANGED
|
@@ -15,7 +15,12 @@ export declare class PostgresError extends Error {
|
|
|
15
15
|
get isTimeout(): boolean;
|
|
16
16
|
get isConnectionFailure(): boolean;
|
|
17
17
|
}
|
|
18
|
+
export declare const ErrNonceMismatch: PostgresError;
|
|
19
|
+
export declare const ErrPasswordRequired: PostgresError;
|
|
20
|
+
export declare const ErrSocketFailedDuringAuth: PostgresError;
|
|
18
21
|
export declare const ErrQueryTimeout: PostgresError;
|
|
22
|
+
export declare const ErrPoolClosed: PostgresError;
|
|
23
|
+
export declare const ErrTransactionClosed: PostgresError;
|
|
19
24
|
export declare const ErrConnectionClosed: PostgresError;
|
|
20
25
|
export declare const ErrConnectionReconnecting: PostgresError;
|
|
21
26
|
//# sourceMappingURL=error.d.ts.map
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;IAEhB,OAAO,EAAE,MAAM;IACxB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;gBART,OAAO,EAAE,MAAM,EACxB,IAAI,GAAE,MAAqB,EAC3B,MAAM,GAAE,MAAW,EACnB,QAAQ,GAAE,MAAW,EACrB,KAAK,GAAE,MAAW,EAClB,IAAI,GAAE,MAAW,E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,eAAiD,CAAA;AAEvF,eAAO,MAAM,eAAe,eAA8C,CAAA;AAE1E,eAAO,MAAM,aAAa,eAAkE,CAAA;AAE5F,eAAO,MAAM,oBAAoB,eAA6E,CAAA;AAE9G,eAAO,MAAM,mBAAmB,eAA8E,CAAA;AAC9G,eAAO,MAAM,yBAAyB,eAA2F,CAAA"}
|
package/dist/error.js
CHANGED
|
@@ -31,6 +31,11 @@ export class PostgresError extends Error {
|
|
|
31
31
|
return this.code.startsWith('08') || this.code.startsWith('57') && this.code !== '57014';
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
export const ErrNonceMismatch = new PostgresError("Protocol violation: server nonce doesn't match client nonce");
|
|
35
|
+
export const ErrPasswordRequired = new PostgresError('The authorization method requires a password.');
|
|
36
|
+
export const ErrSocketFailedDuringAuth = new PostgresError("Socket failed during auth");
|
|
34
37
|
export const ErrQueryTimeout = new PostgresError('Query timeout', '57014');
|
|
38
|
+
export const ErrPoolClosed = new PostgresError("Pool is closed", 'pool_closed', '', "ERROR");
|
|
39
|
+
export const ErrTransactionClosed = new PostgresError("Transaction closed", "transaction_closed", '', "ERROR");
|
|
35
40
|
export const ErrConnectionClosed = new PostgresError("Connection is closed", 'connection_closed', "", "ERROR");
|
|
36
41
|
export const ErrConnectionReconnecting = new PostgresError("Connection are reconnecting", "connection_reconnecting", "", "ERROR");
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EACH,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,mBAAmB,EAEnB,WAAW,EACX,aAAa,EACb,cAAc,EACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC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E,CAAA;AAErC,OAAO,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAA;AAG3B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/pool.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Connection
|
|
1
|
+
import { Connection } from "./connection";
|
|
2
2
|
import { Transaction } from "./transaction";
|
|
3
3
|
import { Future } from "fluent-future";
|
|
4
4
|
import { PostgresError } from "./error";
|
|
5
|
-
|
|
6
|
-
max?: number;
|
|
7
|
-
};
|
|
5
|
+
import { PoolPartialConfig } from "./types";
|
|
8
6
|
/**
|
|
9
7
|
* The main entry point for Pgtx.
|
|
10
8
|
* Manages a connection pool and provides high-level API for queries and transactions.
|
|
@@ -42,13 +40,11 @@ type PoolParams = ConnectionParams & {
|
|
|
42
40
|
*/
|
|
43
41
|
export declare class Pool {
|
|
44
42
|
private _available;
|
|
45
|
-
private
|
|
46
|
-
private _max;
|
|
43
|
+
private config;
|
|
47
44
|
private _total;
|
|
48
45
|
private _waiting;
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
constructor(params: PoolParams);
|
|
46
|
+
private _isOpened;
|
|
47
|
+
constructor(config: PoolPartialConfig);
|
|
52
48
|
/**
|
|
53
49
|
* Acquires a dedicated connection from the pool.
|
|
54
50
|
*
|
|
@@ -186,7 +182,7 @@ export declare class Pool {
|
|
|
186
182
|
* await pool.notify('events', 'hello')
|
|
187
183
|
* ```
|
|
188
184
|
*/
|
|
189
|
-
notify(channelName: string, payload?: string): Future<
|
|
185
|
+
notify(channelName: string, payload?: string): Future<void, PostgresError>;
|
|
190
186
|
/**
|
|
191
187
|
* Asynchronously subscribes to pub/sub events on a specific PostgreSQL channel (LISTEN).
|
|
192
188
|
*
|
|
@@ -211,7 +207,7 @@ export declare class Pool {
|
|
|
211
207
|
* // When the subscription is no longer needed (e.g., during teardown or server stop):
|
|
212
208
|
* await unlisten(); // The socket cleanly issues UNLISTEN and returns to the pool of free connections.
|
|
213
209
|
*/
|
|
214
|
-
listen(channel: string, callback: (payload: string) => void): Future<() =>
|
|
210
|
+
listen(channel: string, callback: (payload: string) => void): Future<() => Future<void, PostgresError>, PostgresError>;
|
|
215
211
|
/**
|
|
216
212
|
* Number of available (idle) connections in the pool.
|
|
217
213
|
*/
|
|
@@ -234,5 +230,4 @@ export declare class Pool {
|
|
|
234
230
|
*/
|
|
235
231
|
close(): void;
|
|
236
232
|
}
|
|
237
|
-
export {};
|
|
238
233
|
//# sourceMappingURL=pool.d.ts.map
|
package/dist/pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,EAAS,MAAM,EAAM,MAAM,eAAe,CAAC;AAClD,OAAO,EAAiB,aAAa,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAc,iBAAiB,EAAU,MAAM,SAAS,CAAC;AAGhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,IAAI;IACb,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,SAAS,CAAO;gBAEZ,MAAM,EAAE,iBAAiB;IAOrC;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO;IA2BP;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC;IAUnD;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,IAAI,EAAE,UAAU;IAiBxB;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IAU7D;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAuBpF;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC;IAoCzG;;;;;;;;;;OAUG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,MAAW;IAQhD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI;IAY3D;;OAEG;IACH,IAAI,IAAI,WAEP;IAGD;;;OAGG;IACH,IAAI,KAAK,WAER;IAGD;;;;;;;;;;OAUG;IACH,KAAK;CAaR"}
|
package/dist/pool.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Connection } from "./connection";
|
|
2
2
|
import { Queue, RingQueue } from "./queue";
|
|
3
3
|
import { Begin, Future, Ok } from "fluent-future";
|
|
4
|
-
import {
|
|
5
|
-
const ErrPoolClosed = new PostgresError('Pool closed');
|
|
4
|
+
import { ErrPoolClosed } from "./error";
|
|
6
5
|
/**
|
|
7
6
|
* The main entry point for Pgtx.
|
|
8
7
|
* Manages a connection pool and provides high-level API for queries and transactions.
|
|
@@ -39,17 +38,13 @@ const ErrPoolClosed = new PostgresError('Pool closed');
|
|
|
39
38
|
* ```
|
|
40
39
|
*/
|
|
41
40
|
export class Pool {
|
|
42
|
-
|
|
43
|
-
if (this._isClosed)
|
|
44
|
-
throw new Error('Pool closed');
|
|
45
|
-
}
|
|
46
|
-
constructor(params) {
|
|
41
|
+
constructor(config) {
|
|
47
42
|
this._total = 0;
|
|
48
43
|
this._waiting = new Queue();
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
this.
|
|
52
|
-
this._available = new RingQueue(this.
|
|
44
|
+
this._isOpened = true;
|
|
45
|
+
const conf = { ...config, max: config.max || 20 };
|
|
46
|
+
this.config = conf;
|
|
47
|
+
this._available = new RingQueue(this.config.max);
|
|
53
48
|
}
|
|
54
49
|
/**
|
|
55
50
|
* Acquires a dedicated connection from the pool.
|
|
@@ -70,7 +65,8 @@ export class Pool {
|
|
|
70
65
|
* ```
|
|
71
66
|
*/
|
|
72
67
|
acquire() {
|
|
73
|
-
this.
|
|
68
|
+
if (!this._isOpened)
|
|
69
|
+
return Future.reject(ErrPoolClosed);
|
|
74
70
|
while (this._available.hasMore) {
|
|
75
71
|
const conn = this._available.shift;
|
|
76
72
|
if (conn.isOpened) {
|
|
@@ -78,9 +74,9 @@ export class Pool {
|
|
|
78
74
|
}
|
|
79
75
|
this._total--;
|
|
80
76
|
}
|
|
81
|
-
if (this._total < this.
|
|
77
|
+
if (this._total < this.config.max) {
|
|
82
78
|
this._total++;
|
|
83
|
-
return Connection.new(this.
|
|
79
|
+
return Connection.new(this.config)
|
|
84
80
|
.tapErr(() => this._total--);
|
|
85
81
|
}
|
|
86
82
|
const { future, reject, resolve } = Future.withResolvers();
|
|
@@ -130,7 +126,8 @@ export class Pool {
|
|
|
130
126
|
* ```
|
|
131
127
|
*/
|
|
132
128
|
release(conn) {
|
|
133
|
-
this.
|
|
129
|
+
if (!this._isOpened)
|
|
130
|
+
throw ErrPoolClosed;
|
|
134
131
|
if (!conn.isOpened) {
|
|
135
132
|
this._total--;
|
|
136
133
|
return;
|
|
@@ -160,7 +157,6 @@ export class Pool {
|
|
|
160
157
|
* ```
|
|
161
158
|
*/
|
|
162
159
|
begin(txCallback) {
|
|
163
|
-
this._checkClosed();
|
|
164
160
|
return Begin()
|
|
165
161
|
.andThen(() => this.acquire())
|
|
166
162
|
.andThen(conn => conn.begin(txCallback)
|
|
@@ -190,7 +186,8 @@ export class Pool {
|
|
|
190
186
|
* ```
|
|
191
187
|
*/
|
|
192
188
|
query(templates, ...args) {
|
|
193
|
-
this.
|
|
189
|
+
if (!this._isOpened)
|
|
190
|
+
return Future.reject(ErrPoolClosed);
|
|
194
191
|
while (this._available.hasMore) {
|
|
195
192
|
const conn = this._available.shift;
|
|
196
193
|
if (!conn.isOpened) {
|
|
@@ -232,7 +229,8 @@ export class Pool {
|
|
|
232
229
|
* }
|
|
233
230
|
*/
|
|
234
231
|
stream(templates, ...args) {
|
|
235
|
-
this.
|
|
232
|
+
if (!this._isOpened)
|
|
233
|
+
throw ErrPoolClosed;
|
|
236
234
|
while (this._available.hasMore) {
|
|
237
235
|
const conn = this._available.shift;
|
|
238
236
|
if (!conn.isOpened) {
|
|
@@ -270,7 +268,9 @@ export class Pool {
|
|
|
270
268
|
* ```
|
|
271
269
|
*/
|
|
272
270
|
notify(channelName, payload = "") {
|
|
273
|
-
return this.
|
|
271
|
+
return this.acquire()
|
|
272
|
+
.andThen(conn => conn.notify(channelName, payload)
|
|
273
|
+
.finally(() => this.release(conn)));
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
276
276
|
* Asynchronously subscribes to pub/sub events on a specific PostgreSQL channel (LISTEN).
|
|
@@ -299,10 +299,8 @@ export class Pool {
|
|
|
299
299
|
listen(channel, callback) {
|
|
300
300
|
return this.acquire()
|
|
301
301
|
.andThen(conn => conn.listen(channel, callback)
|
|
302
|
-
.map(() =>
|
|
303
|
-
|
|
304
|
-
this.release(conn);
|
|
305
|
-
}));
|
|
302
|
+
.map(() => () => conn.unlisten(channel, callback)
|
|
303
|
+
.tap(() => this.release(conn))));
|
|
306
304
|
}
|
|
307
305
|
/**
|
|
308
306
|
* Number of available (idle) connections in the pool.
|
|
@@ -329,6 +327,7 @@ export class Pool {
|
|
|
329
327
|
* ```
|
|
330
328
|
*/
|
|
331
329
|
close() {
|
|
330
|
+
this._isOpened = false;
|
|
332
331
|
while (this._available.hasMore) {
|
|
333
332
|
this._available.shift.close();
|
|
334
333
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AuthenticationCode, ResponseType, TransactionStatus } from "./constants";
|
|
2
|
-
import { ColumnDescription } from "../types";
|
|
2
|
+
import { ChannelName, ColumnDescription } from "../types";
|
|
3
3
|
import { PostgresError } from "../error";
|
|
4
|
-
import { ChannelName } from "../connection";
|
|
5
4
|
export declare class ConnectionResponseBuffer {
|
|
6
5
|
private buffer;
|
|
7
6
|
private caret;
|
|
@@ -31,7 +30,6 @@ export declare class ConnectionResponseBuffer {
|
|
|
31
30
|
}
|
|
32
31
|
export declare class ConnectionResponseReader {
|
|
33
32
|
private buffer;
|
|
34
|
-
private currentPacketLength;
|
|
35
33
|
private constructor();
|
|
36
34
|
static from(buffer: Buffer): ConnectionResponseReader;
|
|
37
35
|
readType(): {
|
|
@@ -53,7 +51,7 @@ export declare class ConnectionResponseReader {
|
|
|
53
51
|
readSaslMechanisms(): string[];
|
|
54
52
|
readSaslMessage(length: number): string;
|
|
55
53
|
readRowDescription(): ColumnDescription[];
|
|
56
|
-
readDataRow(descriptions: ColumnDescription[], int8toBigint
|
|
54
|
+
readDataRow(descriptions: ColumnDescription[], int8toBigint: boolean): Record<string, any>;
|
|
57
55
|
readNotificationResponse(): {
|
|
58
56
|
name: ChannelName;
|
|
59
57
|
payload: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-response-reader.d.ts","sourceRoot":"","sources":["../../src/protocol/connection-response-reader.ts"],"names":[],"mappings":"AAAA,OAA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;cACoC,YAAY;;;IAIxD,kBAAkB,IACoB,kBAAkB;IAIxD,WAAW;IAKX,mBAAmB;;;;IAQnB,kBAAkB;;;;IAQlB,iBAAiB,IAAI,aAAa;IA4ClC,iBAAiB,IACoB,iBAAiB;IAItD,kBAAkB,IAAI,MAAM,EAAE;IAa9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAKvC,kBAAkB;IAsBlB,WAAW,CAAC,YAAY,EAAE,iBAAiB,EAAE,EAAE,YAAY,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA0G1F,wBAAwB;;;;IASxB,mBAAmB,IAAI,MAAM;IAK7B,OAAO;IAKP,aAAa;IAKb,iBAAiB;IAKjB,iBAAiB;IAGjB,gBAAgB;IAGhB,wBAAwB;IAOxB,UAAU;CACb"}
|
|
@@ -131,7 +131,6 @@ export class ConnectionResponseBuffer {
|
|
|
131
131
|
export class ConnectionResponseReader {
|
|
132
132
|
constructor(buffer) {
|
|
133
133
|
this.buffer = buffer;
|
|
134
|
-
this.currentPacketLength = 0;
|
|
135
134
|
}
|
|
136
135
|
static from(buffer) {
|
|
137
136
|
return new ConnectionResponseReader(ConnectionResponseBuffer.from(buffer));
|
|
@@ -236,7 +235,7 @@ export class ConnectionResponseReader {
|
|
|
236
235
|
}
|
|
237
236
|
return columns;
|
|
238
237
|
}
|
|
239
|
-
readDataRow(descriptions, int8toBigint
|
|
238
|
+
readDataRow(descriptions, int8toBigint) {
|
|
240
239
|
const fieldsCount = this.buffer.readInt16();
|
|
241
240
|
const row = {};
|
|
242
241
|
for (let i = 0; i < fieldsCount; i++) {
|
|
@@ -2,15 +2,6 @@ import { Socket } from "node:net";
|
|
|
2
2
|
import { ConnectionRequestWriter } from "./connection-request-writer";
|
|
3
3
|
import { PostgresError } from "../error";
|
|
4
4
|
import { Future } from "fluent-future";
|
|
5
|
-
|
|
6
|
-
host: string;
|
|
7
|
-
port: number;
|
|
8
|
-
user: string;
|
|
9
|
-
database: string;
|
|
10
|
-
password?: string;
|
|
11
|
-
};
|
|
12
|
-
export declare const ErrNonceMismatch: PostgresError;
|
|
13
|
-
export declare const ErrPasswordRequired: PostgresError;
|
|
14
|
-
export declare const ErrSocketFailedDuringAuth: PostgresError;
|
|
5
|
+
import { AuthorizationParams } from "../types";
|
|
15
6
|
export declare const createAuthorizedSocket: (writer: ConnectionRequestWriter, params: AuthorizationParams) => Future<Socket, PostgresError>;
|
|
16
7
|
//# sourceMappingURL=socket-authorization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-authorization.d.ts","sourceRoot":"","sources":["../../src/protocol/socket-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAKrE,OAAO,
|
|
1
|
+
{"version":3,"file":"socket-authorization.d.ts","sourceRoot":"","sources":["../../src/protocol/socket-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAKrE,OAAO,EAAoE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC1G,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAG9C,eAAO,MAAM,sBAAsB,GAAI,QAAQ,uBAAuB,EAAE,QAAQ,mBAAmB,kCAoHlG,CAAA"}
|
|
@@ -3,11 +3,8 @@ import { calculateScramAuth, generateNonce } from "../security/sasl";
|
|
|
3
3
|
import { SocketConnector } from "./socket-connector";
|
|
4
4
|
import { AuthenticationCodes, ResponseTypes } from "./constants";
|
|
5
5
|
import { encryptMd5 } from "../security/md5";
|
|
6
|
-
import {
|
|
6
|
+
import { ErrNonceMismatch, ErrPasswordRequired, ErrSocketFailedDuringAuth } from "../error";
|
|
7
7
|
import { Future } from "fluent-future";
|
|
8
|
-
export const ErrNonceMismatch = new PostgresError("Protocol violation: server nonce doesn't match client nonce");
|
|
9
|
-
export const ErrPasswordRequired = new PostgresError('The authorization method requires a password.');
|
|
10
|
-
export const ErrSocketFailedDuringAuth = new PostgresError("Socket failed during auth");
|
|
11
8
|
export const createAuthorizedSocket = (writer, params) => {
|
|
12
9
|
const { future, reject, resolve } = Future.withResolvers();
|
|
13
10
|
const nonce = generateNonce();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-connector.d.ts","sourceRoot":"","sources":["../../src/protocol/socket-connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAA;AAE/E,qBAAa,eAAe;IAKpB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,QAAQ;IANpB,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,YAAY,CAAQ;gBAGhB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,KAAK,IAAI,EACvF,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;IA8B5C,KAAK,CAAC,MAAM,EAAE,uBAAuB;
|
|
1
|
+
{"version":3,"file":"socket-connector.d.ts","sourceRoot":"","sources":["../../src/protocol/socket-connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAA;AAE/E,qBAAa,eAAe;IAKpB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,QAAQ;IANpB,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,YAAY,CAAQ;gBAGhB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,KAAK,IAAI,EACvF,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;IA8B5C,KAAK,CAAC,MAAM,EAAE,uBAAuB;IAMrC,YAAY;IAQZ,OAAO;IAMP,IAAI,WAAW,YAA6B;CAC/C"}
|
package/dist/query.d.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { Future } from "fluent-future";
|
|
2
|
-
import { QueryMeta, QueryText, StatementName } from "./
|
|
3
|
-
import { ColumnDescription, ValueOF } from "./types";
|
|
2
|
+
import { ColumnDescription, QueryMeta, QueryText, StatementName } from "./types";
|
|
4
3
|
import { PostgresError } from "./error";
|
|
5
|
-
export declare const QueryState: {
|
|
6
|
-
readonly Parsing: 0;
|
|
7
|
-
readonly Executing: 1;
|
|
8
|
-
readonly Completed: 2;
|
|
9
|
-
readonly Failed: 3;
|
|
10
|
-
};
|
|
11
|
-
export type State = ValueOF<typeof QueryState>;
|
|
12
4
|
export declare abstract class Query {
|
|
13
5
|
statement: StatementName;
|
|
14
6
|
protected _timer?: NodeJS.Timeout;
|
|
15
|
-
constructor(statement: StatementName);
|
|
16
|
-
startTimeout(timeout: number): void;
|
|
7
|
+
constructor(statement: StatementName, timeout: number);
|
|
17
8
|
abstract reject(cause: PostgresError): void;
|
|
18
9
|
abstract resolve(...args: any[]): void;
|
|
19
10
|
}
|
|
@@ -25,7 +16,7 @@ export declare class SimpleQuery<T> extends Query {
|
|
|
25
16
|
private _resolve;
|
|
26
17
|
private _reject;
|
|
27
18
|
private _rows;
|
|
28
|
-
constructor(statement: StatementName, text: QueryText, args: (string | null)[], columns: ColumnDescription[]);
|
|
19
|
+
constructor(statement: StatementName, text: QueryText, args: (string | null)[], columns: ColumnDescription[], timeout: number);
|
|
29
20
|
push(value: T): void;
|
|
30
21
|
reject(cause: PostgresError): void;
|
|
31
22
|
resolve(): void;
|
|
@@ -35,7 +26,7 @@ export declare class ParseQuery extends Query {
|
|
|
35
26
|
future: Future<QueryMeta, PostgresError>;
|
|
36
27
|
private _resolve;
|
|
37
28
|
private _reject;
|
|
38
|
-
constructor(statement: StatementName, text: QueryText);
|
|
29
|
+
constructor(statement: StatementName, text: QueryText, timeout: number);
|
|
39
30
|
reject(cause: PostgresError): void;
|
|
40
31
|
resolve(meta: QueryMeta): void;
|
|
41
32
|
}
|
|
@@ -44,7 +35,7 @@ export declare class StreamQuery<T> extends Query {
|
|
|
44
35
|
args: (string | null)[];
|
|
45
36
|
controller: ReadableStreamDefaultController<T>;
|
|
46
37
|
columns: ColumnDescription[];
|
|
47
|
-
constructor(statement: StatementName, text: QueryText, args: (string | null)[], controller: ReadableStreamDefaultController<T>, columns: ColumnDescription[]);
|
|
38
|
+
constructor(statement: StatementName, text: QueryText, args: (string | null)[], controller: ReadableStreamDefaultController<T>, columns: ColumnDescription[], timeout: number);
|
|
48
39
|
push(value: T): void;
|
|
49
40
|
reject(cause: PostgresError): void;
|
|
50
41
|
resolve(): void;
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAA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IAAI,EAAE,SAAS,EACtB,OAAO,EAAE,MAAM;IAWnB,MAAM,CAAC,KAAK,EAAE,aAAa;IAM3B,OAAO,CAAC,IAAI,EAAE,SAAS;CAI1B;AAGD,qBAAa,WAAW,CAAC,CAAC,CAAE,SAAQ,KAAK;IAG1B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE;IACvB,UAAU,EAAE,+BAA+B,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAE,iBAAiB,EAAE;gBAJnC,SAAS,EAAE,aAAa,EACjB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,EACvB,UAAU,EAAE,+BAA+B,CAAC,CAAC,CAAC,EAC9C,OAAO,EAAE,iBAAiB,EAAE,EACnC,OAAO,EAAE,MAAM;IAMnB,IAAI,CAAC,KAAK,EAAE,CAAC;IAKb,MAAM,CAAC,KAAK,EAAE,aAAa;IAM3B,OAAO;CAIV;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,CAAA"}
|
package/dist/query.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { Future } from "fluent-future";
|
|
2
2
|
import { ErrQueryTimeout } from "./error";
|
|
3
|
-
export const QueryState = {
|
|
4
|
-
Parsing: 0,
|
|
5
|
-
Executing: 1,
|
|
6
|
-
Completed: 2,
|
|
7
|
-
Failed: 3
|
|
8
|
-
};
|
|
9
3
|
export class Query {
|
|
10
|
-
constructor(statement) {
|
|
4
|
+
constructor(statement, timeout) {
|
|
11
5
|
this.statement = statement;
|
|
12
|
-
}
|
|
13
|
-
startTimeout(timeout) {
|
|
14
6
|
this._timer = setTimeout(() => {
|
|
15
7
|
this.reject(ErrQueryTimeout);
|
|
16
8
|
}, timeout);
|
|
17
9
|
}
|
|
18
10
|
}
|
|
19
11
|
export class SimpleQuery extends Query {
|
|
20
|
-
constructor(statement, text, args, columns) {
|
|
21
|
-
super(statement);
|
|
12
|
+
constructor(statement, text, args, columns, timeout) {
|
|
13
|
+
super(statement, timeout);
|
|
22
14
|
this.text = text;
|
|
23
15
|
this.args = args;
|
|
24
16
|
this.columns = columns;
|
|
@@ -41,8 +33,8 @@ export class SimpleQuery extends Query {
|
|
|
41
33
|
}
|
|
42
34
|
}
|
|
43
35
|
export class ParseQuery extends Query {
|
|
44
|
-
constructor(statement, text) {
|
|
45
|
-
super(statement);
|
|
36
|
+
constructor(statement, text, timeout) {
|
|
37
|
+
super(statement, timeout);
|
|
46
38
|
this.text = text;
|
|
47
39
|
const { future, reject, resolve } = Future.withResolvers();
|
|
48
40
|
this.future = future;
|
|
@@ -59,8 +51,8 @@ export class ParseQuery extends Query {
|
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
53
|
export class StreamQuery extends Query {
|
|
62
|
-
constructor(statement, text, args, controller, columns) {
|
|
63
|
-
super(statement);
|
|
54
|
+
constructor(statement, text, args, controller, columns, timeout) {
|
|
55
|
+
super(statement, timeout);
|
|
64
56
|
this.text = text;
|
|
65
57
|
this.args = args;
|
|
66
58
|
this.controller = controller;
|
package/dist/transaction.d.ts
CHANGED
|
@@ -13,15 +13,14 @@ export declare class Transaction {
|
|
|
13
13
|
* Returns true if the transaction is still open (not committed or rolled back).
|
|
14
14
|
*/
|
|
15
15
|
get isActive(): boolean;
|
|
16
|
-
private checkActive;
|
|
17
16
|
/**
|
|
18
17
|
* Commits the current transaction.
|
|
19
18
|
*/
|
|
20
|
-
commit(): Future<
|
|
19
|
+
commit(): Future<void, PostgresError>;
|
|
21
20
|
/**
|
|
22
21
|
* Rolls back the current transaction.
|
|
23
22
|
*/
|
|
24
|
-
rollback(): Future<
|
|
23
|
+
rollback(): Future<void, PostgresError>;
|
|
25
24
|
/**
|
|
26
25
|
* Executes a query within the current transaction.
|
|
27
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAwB,aAAa,EAAE,MAAM,SAAS,CAAA;AAE7D;;;GAGG;AACH,qBAAa,WAAW;IAIhB,QAAQ,CAAC,IAAI,EAAE,UAAU;IAH7B,OAAO,CAAC,UAAU,CAAiB;gBAGtB,IAAI,EAAE,UAAU;IAG7B;;OAEG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED;;OAEG;IACI,MAAM;IAQb;;OAEG;IACI,QAAQ;IAQf;;OAEG;IACI,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE;IAM3F;;;;;;;;;OASG;IACI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;CAW9E"}
|
package/dist/transaction.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Begin, Future } from "fluent-future";
|
|
2
2
|
import { IdentifierClause } from "./clauses";
|
|
3
|
+
import { ErrTransactionClosed } from "./error";
|
|
3
4
|
/**
|
|
4
5
|
* Represents an active SQL transaction.
|
|
5
6
|
* All queries are executed on a single dedicated connection.
|
|
@@ -15,32 +16,32 @@ export class Transaction {
|
|
|
15
16
|
get isActive() {
|
|
16
17
|
return !this.isFinished;
|
|
17
18
|
}
|
|
18
|
-
checkActive() {
|
|
19
|
-
if (this.isFinished) {
|
|
20
|
-
throw new Error("Transaction is finished");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
19
|
/**
|
|
24
20
|
* Commits the current transaction.
|
|
25
21
|
*/
|
|
26
22
|
commit() {
|
|
27
|
-
this.
|
|
23
|
+
if (this.isFinished)
|
|
24
|
+
return Future.reject(ErrTransactionClosed);
|
|
28
25
|
return this.conn.query `COMMIT`
|
|
29
|
-
.tap(() => this.isFinished = true)
|
|
26
|
+
.tap(() => this.isFinished = true)
|
|
27
|
+
.map(() => { });
|
|
30
28
|
}
|
|
31
29
|
/**
|
|
32
30
|
* Rolls back the current transaction.
|
|
33
31
|
*/
|
|
34
32
|
rollback() {
|
|
35
|
-
this.
|
|
33
|
+
if (this.isFinished)
|
|
34
|
+
return Future.reject(ErrTransactionClosed);
|
|
36
35
|
return this.conn.query `ROLLBACK`
|
|
37
|
-
.tap(() => this.isFinished = true)
|
|
36
|
+
.tap(() => this.isFinished = true)
|
|
37
|
+
.map(() => { });
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Executes a query within the current transaction.
|
|
41
41
|
*/
|
|
42
42
|
query(strings, ...values) {
|
|
43
|
-
this.
|
|
43
|
+
if (this.isFinished)
|
|
44
|
+
return Future.reject(ErrTransactionClosed);
|
|
44
45
|
return this.conn.query(strings, ...values);
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
@@ -54,7 +55,8 @@ export class Transaction {
|
|
|
54
55
|
* });
|
|
55
56
|
*/
|
|
56
57
|
savepoint(name, callback) {
|
|
57
|
-
this.
|
|
58
|
+
if (this.isFinished)
|
|
59
|
+
return Future.reject(ErrTransactionClosed);
|
|
58
60
|
return Begin()
|
|
59
61
|
.andThen(() => this.conn.query `SAVEPOINT ${IdentifierClause.create(name)}`)
|
|
60
62
|
.andThen(() => Future.of(callback(this))
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Connection } from "./connection";
|
|
2
|
+
import { PostgresError } from "./error";
|
|
1
3
|
import { DataTypeOid } from "./protocol/constants";
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
name: string;
|
|
5
|
-
execute: (...args: Tparams) => Promise<TResult[]>;
|
|
4
|
+
export type Branded<T, Brand> = T & {
|
|
5
|
+
__brand: Brand;
|
|
6
6
|
};
|
|
7
|
+
export type ValueOF<T extends Record<string, unknown>> = T[keyof T];
|
|
7
8
|
export type CompiledSqlQuery = {
|
|
8
9
|
text: string;
|
|
9
10
|
args: (string | null)[];
|
|
@@ -12,16 +13,56 @@ export type ClauseStrategyParams = {
|
|
|
12
13
|
text: string;
|
|
13
14
|
args: any[];
|
|
14
15
|
};
|
|
15
|
-
export type CompileSQLParams = {
|
|
16
|
-
templates: TemplateStringsArray;
|
|
17
|
-
args: any[];
|
|
18
|
-
};
|
|
19
16
|
export type ColumnDescription = {
|
|
20
17
|
name: string;
|
|
21
18
|
typeOID: DataTypeOid;
|
|
22
19
|
};
|
|
23
|
-
export type
|
|
24
|
-
|
|
20
|
+
export type AuthorizationParams = {
|
|
21
|
+
host: string;
|
|
22
|
+
port: number;
|
|
23
|
+
user: string;
|
|
24
|
+
database: string;
|
|
25
|
+
password?: string;
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
+
type LogLevel = "none" | "error" | "notice" | "query";
|
|
28
|
+
export type ConnectionPartialConfig = {
|
|
29
|
+
user: string;
|
|
30
|
+
password?: string;
|
|
31
|
+
host: string;
|
|
32
|
+
port: number;
|
|
33
|
+
database: string;
|
|
34
|
+
logLevel?: LogLevel;
|
|
35
|
+
int8toBigint?: boolean;
|
|
36
|
+
queryTimeout?: number;
|
|
37
|
+
syncShedule?: "Tick" | "Immediate";
|
|
38
|
+
};
|
|
39
|
+
export type ConnectionConfig = {
|
|
40
|
+
user: string;
|
|
41
|
+
password?: string;
|
|
42
|
+
host: string;
|
|
43
|
+
port: number;
|
|
44
|
+
database: string;
|
|
45
|
+
logLevel: LogLevel;
|
|
46
|
+
int8toBigint: boolean;
|
|
47
|
+
queryTimeout: number;
|
|
48
|
+
syncShedule: "Tick" | "Immediate";
|
|
49
|
+
};
|
|
50
|
+
export type StatementName = Branded<string, 'StatementName'>;
|
|
51
|
+
export type QueryText = Branded<string, 'QueryText'>;
|
|
52
|
+
export type ChannelName = Branded<string, "ChannelName">;
|
|
53
|
+
export type QueryMeta = {
|
|
54
|
+
statement: StatementName;
|
|
55
|
+
columns: ColumnDescription[];
|
|
56
|
+
};
|
|
57
|
+
export type PoolPartialConfig = ConnectionPartialConfig & {
|
|
58
|
+
max?: number;
|
|
59
|
+
};
|
|
60
|
+
export type PoolConfig = ConnectionPartialConfig & {
|
|
61
|
+
max: number;
|
|
62
|
+
};
|
|
63
|
+
export type Waiter = {
|
|
64
|
+
resolve: (conn: Connection) => void;
|
|
65
|
+
reject: (err: PostgresError) => void;
|
|
66
|
+
};
|
|
67
|
+
export {};
|
|
27
68
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,GAAG;IAAC,OAAO,EAAE,KAAK,CAAA;CAAC,CAAA;AAEpD,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAEnE,MA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