-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export connection and query diagnostics_channel (#111)
Drop Node.js < 16.17.0 support
- Loading branch information
Showing
12 changed files
with
160 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "eslint-config-egg/typescript" | ||
"extends": [ | ||
"eslint-config-egg/typescript", | ||
"eslint-config-egg/lib/rules/enforce-node-prefix" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
"version": "6.1.0", | ||
"description": "Aliyun RDS client", | ||
"main": "lib/client.js", | ||
"types": "lib/client.d.ts", | ||
"files": [ | ||
"lib" | ||
], | ||
|
@@ -43,7 +44,7 @@ | |
"mysql" | ||
], | ||
"engines": { | ||
"node": ">= 14.17.0" | ||
"node": ">= 16.17.0" | ||
}, | ||
"author": "fengmk2 <[email protected]> (https://github.com/fengmk2)", | ||
"license": "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import diagnosticsChannel from 'node:diagnostics_channel'; | ||
import type { PoolConnectionPromisify } from './types'; | ||
import type { RDSClient } from './client'; | ||
|
||
export default { | ||
// pool events https://github.com/mysqljs/mysql#pool-events | ||
connectionNew: diagnosticsChannel.channel('ali-rds:connection:new'), | ||
connectionAcquire: diagnosticsChannel.channel('ali-rds:connection:acquire'), | ||
connectionRelease: diagnosticsChannel.channel('ali-rds:connection:release'), | ||
connectionEnqueue: diagnosticsChannel.channel('ali-rds:connection:enqueue'), | ||
// query | ||
queryStart: diagnosticsChannel.channel('ali-rds:query:start'), | ||
queryEnd: diagnosticsChannel.channel('ali-rds:query:end'), | ||
}; | ||
|
||
export interface ConnectionMessage { | ||
client: RDSClient; | ||
connection: PoolConnectionPromisify; | ||
} | ||
|
||
export interface ConnectionEnqueueMessage { | ||
client: RDSClient; | ||
} | ||
|
||
export interface QueryStartMessage { | ||
connection: PoolConnectionPromisify; | ||
sql: string; | ||
} | ||
|
||
export interface QueryEndMessage { | ||
connection: PoolConnectionPromisify; | ||
sql: string; | ||
duration: number; | ||
error?: Error; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { AsyncLocalStorage } from 'async_hooks'; | ||
import { AsyncLocalStorage } from 'node:async_hooks'; | ||
import { strict as assert } from 'node:assert'; | ||
import fs from 'node:fs/promises'; | ||
import path from 'node:path'; | ||
|
@@ -1315,6 +1315,8 @@ describe('test/client.test.ts', () => { | |
assert(result.insertId > 0); | ||
result = await conn.delete(table); | ||
assert(result.affectedRows > 0); | ||
assert.equal(typeof conn.threadId, 'number'); | ||
assert(conn.threadId! > 0); | ||
conn.release(); | ||
}); | ||
}); | ||
|
@@ -1417,6 +1419,9 @@ describe('test/client.test.ts', () => { | |
assert.equal(count, 1); | ||
|
||
await db.beginTransactionScope(async conn => { | ||
assert.equal(typeof conn.threadId, 'number'); | ||
assert(conn.threadId! > 0); | ||
assert.equal(conn.threadId, conn.conn!.threadId); | ||
await conn.query(`insert into ??(name, email, gmt_create, gmt_modified) | ||
values(?, ?, now(), now())`, | ||
[ table, prefix + 'beginTransactionScope1', prefix + '[email protected]' ]); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters