@trenskow/pged 5.1.70 → 5.1.71
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/lib/index.js +12 -3
- package/package.json +2 -1
package/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import Puqeue from 'puqeue';
|
|
|
10
10
|
import caseit from '@trenskow/caseit';
|
|
11
11
|
import pg from 'pg';
|
|
12
12
|
import EventEmitter from '@trenskow/async-event-emitter';
|
|
13
|
+
import wait from '@trenskow/wait';
|
|
13
14
|
|
|
14
15
|
import QueryBuilder from './query-builder.js';
|
|
15
16
|
|
|
@@ -44,7 +45,11 @@ export default class PGed extends EventEmitter {
|
|
|
44
45
|
options.casing = options.casing || {};
|
|
45
46
|
options.casing.db = options.casing.db || 'snake';
|
|
46
47
|
options.casing.js = options.casing.hs || 'camel';
|
|
47
|
-
|
|
48
|
+
|
|
49
|
+
options.connection = options.connection || {};
|
|
50
|
+
options.connection.retry = options.connection.retry || {};
|
|
51
|
+
options.connection.retry.count = options.connection.retry.count || 1;
|
|
52
|
+
options.connection.retry.delay = options.connection.retry.delay || '0s';
|
|
48
53
|
|
|
49
54
|
options.defaultPrimaryKey = options.defaultPrimaryKey || 'id';
|
|
50
55
|
|
|
@@ -117,15 +122,19 @@ export default class PGed extends EventEmitter {
|
|
|
117
122
|
|
|
118
123
|
let connectionCount = 0;
|
|
119
124
|
|
|
120
|
-
while (connectionCount < this._options.
|
|
125
|
+
while (connectionCount < this._options.connection.retry.count) {
|
|
121
126
|
try {
|
|
122
127
|
connectionCount++;
|
|
123
128
|
this._client = await pool.connect();
|
|
124
129
|
break;
|
|
125
130
|
} catch (error) {
|
|
126
|
-
|
|
131
|
+
|
|
132
|
+
if (connectionCount == this._options.connection.retry.count) {
|
|
127
133
|
throw error;
|
|
128
134
|
}
|
|
135
|
+
|
|
136
|
+
await wait(this._options.connectionRetryDelay);
|
|
137
|
+
|
|
129
138
|
}
|
|
130
139
|
}
|
|
131
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trenskow/pged",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.71",
|
|
4
4
|
"description": "Just a silly little db management and query builder for PostgreSQL.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@trenskow/caseit": "^1.4.12",
|
|
28
28
|
"@trenskow/custom-promise": "^0.13.9",
|
|
29
29
|
"@trenskow/parse": "^0.1.33",
|
|
30
|
+
"@trenskow/wait": "^1.3.60",
|
|
30
31
|
"pg": "^8.16.0",
|
|
31
32
|
"puqeue": "^1.1.17"
|
|
32
33
|
},
|