velocious 1.0.57 → 1.0.59
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/package.json +2 -2
- package/src/database/drivers/base.js +7 -7
- package/src/logger.js +15 -3
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"velocious": "bin/velocious.js"
|
|
4
4
|
},
|
|
5
5
|
"name": "velocious",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.59",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "VELOCIOUS_TEST_DIR=../ cd spec/dummy && npx velocious test",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"homepage": "https://github.com/kaspernj/velocious#readme",
|
|
23
23
|
"description": "",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"async-mutex": "^0.5.0",
|
|
26
25
|
"awaitery": "^1.0.1",
|
|
27
26
|
"bcryptjs": "^3.0.2",
|
|
28
27
|
"better-localstorage": "^1.0.7",
|
|
@@ -30,6 +29,7 @@
|
|
|
30
29
|
"diggerize": "^1.0.5",
|
|
31
30
|
"ejs": "^3.1.6",
|
|
32
31
|
"env-sense": "^1.0.0",
|
|
32
|
+
"epic-locks": "^1.0.3",
|
|
33
33
|
"escape-string-regexp": "^1.0.5",
|
|
34
34
|
"incorporator": "^1.0.2",
|
|
35
35
|
"inflection": "^3.0.0",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {Logger} from "../../logger.js"
|
|
2
2
|
import Query from "../query/index.js"
|
|
3
3
|
import Handler from "../handler.js"
|
|
4
|
+
import Mutex from "epic-locks/src/mutex.js"
|
|
4
5
|
import strftime from "strftime"
|
|
5
6
|
import UUID from "pure-uuid"
|
|
6
7
|
import TableData from "../table-data/index.js"
|
|
7
8
|
import TableColumn from "../table-data/table-column.js"
|
|
8
9
|
import TableForeignKey from "../table-data/table-foreign-key.js"
|
|
9
|
-
import {Mutex} from "async-mutex"
|
|
10
10
|
|
|
11
11
|
export default class VelociousDatabaseDriversBase {
|
|
12
12
|
constructor(config, configuration) {
|
|
@@ -209,7 +209,7 @@ export default class VelociousDatabaseDriversBase {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
async startTransaction() {
|
|
212
|
-
await this._transactionsActionsMutex.
|
|
212
|
+
await this._transactionsActionsMutex.sync(async () => {
|
|
213
213
|
await this._startTransactionAction()
|
|
214
214
|
this._transactionsCount++
|
|
215
215
|
})
|
|
@@ -220,7 +220,7 @@ export default class VelociousDatabaseDriversBase {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
async commitTransaction() {
|
|
223
|
-
await this._transactionsActionsMutex.
|
|
223
|
+
await this._transactionsActionsMutex.sync(async () => {
|
|
224
224
|
await this._commitTransactionAction()
|
|
225
225
|
this._transactionsCount--
|
|
226
226
|
})
|
|
@@ -231,7 +231,7 @@ export default class VelociousDatabaseDriversBase {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
async rollbackTransaction() {
|
|
234
|
-
await this._transactionsActionsMutex.
|
|
234
|
+
await this._transactionsActionsMutex.sync(async () => {
|
|
235
235
|
await this._rollbackTransactionAction()
|
|
236
236
|
this._transactionsCount--
|
|
237
237
|
})
|
|
@@ -246,7 +246,7 @@ export default class VelociousDatabaseDriversBase {
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
async startSavePoint(savePointName) {
|
|
249
|
-
await this._transactionsActionsMutex.
|
|
249
|
+
await this._transactionsActionsMutex.sync(async () => {
|
|
250
250
|
await this._startSavePointAction(savePointName)
|
|
251
251
|
})
|
|
252
252
|
}
|
|
@@ -272,7 +272,7 @@ export default class VelociousDatabaseDriversBase {
|
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
async releaseSavePoint(savePointName) {
|
|
275
|
-
await this._transactionsActionsMutex.
|
|
275
|
+
await this._transactionsActionsMutex.sync(async () => {
|
|
276
276
|
await this._releaseSavePointAction(savePointName)
|
|
277
277
|
})
|
|
278
278
|
}
|
|
@@ -282,7 +282,7 @@ export default class VelociousDatabaseDriversBase {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
async rollbackSavePoint(savePointName) {
|
|
285
|
-
await this._transactionsActionsMutex.
|
|
285
|
+
await this._transactionsActionsMutex.sync(async () => {
|
|
286
286
|
await this._rollbackSavePointAction(savePointName)
|
|
287
287
|
})
|
|
288
288
|
}
|
package/src/logger.js
CHANGED
|
@@ -2,19 +2,31 @@ import Configuration from "./configuration.js"
|
|
|
2
2
|
|
|
3
3
|
function consoleLog(message) {
|
|
4
4
|
return new Promise((resolve) => {
|
|
5
|
-
process.stdout
|
|
5
|
+
if (process.stdout) {
|
|
6
|
+
process.stdout.write(`${message}\n`, "utf8", resolve)
|
|
7
|
+
} else {
|
|
8
|
+
console.log(message)
|
|
9
|
+
}
|
|
6
10
|
})
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
function consoleError(message) {
|
|
10
14
|
return new Promise((resolve) => {
|
|
11
|
-
process.stderr
|
|
15
|
+
if (process.stderr) {
|
|
16
|
+
process.stderr.write(`${message}\n`, "utf8", resolve)
|
|
17
|
+
} else {
|
|
18
|
+
console.error(message)
|
|
19
|
+
}
|
|
12
20
|
})
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
function consoleWarn(message) {
|
|
16
24
|
return new Promise((resolve) => {
|
|
17
|
-
process.stderr
|
|
25
|
+
if (process.stderr) {
|
|
26
|
+
process.stderr.write(`${message}\n`, "utf8", resolve)
|
|
27
|
+
} else {
|
|
28
|
+
console.warn(message)
|
|
29
|
+
}
|
|
18
30
|
})
|
|
19
31
|
}
|
|
20
32
|
|