[英]Node.js Oracle DB connection pool. How to log how many connections are currently open
我是 Node JS 世界的新手。 我在我的應用程序中使用 Oracle 數據庫並創建連接池。 使用此連接池查詢數據庫。 應用程序運行良好,但對於我的測試,我需要記錄每次查詢后打開了多少連接。
如何記錄打開的連接數。
下面是我創建連接池的代碼:
async function bbUserPool() {
try {
await oracledb.createPool({
user : config.user,
password : config.password,
connectString : config.connectString,
poolAlias : 'userpool',
poolIncrement : 10,
poolMax : 20,
poolMin : 20
});
}
catch (err) {
console.error("Connection Pool Error:" + err.message)
}
}
如何記錄打開的連接數。
node-oracledb 文檔連接池監控提供了有用的信息。
池屬性 connectionsInUse 和 connectionsOpen 始終提供有關活動池的基本信息:
const pool = await oracledb.createPool(...); . . . console.log(pool.connectionsOpen); // how big the pool actually is console.log(pool.connectionsInUse); // how many of those connections are held by the application
這是從池實現的角度來看的。 connectionsOpen
值是已經建立到數據庫的“管道”(為了更好的詞)的數量。 在您的示例中,我希望這在正常操作中為 20。 connectionsInUse
值是沒有顯式或隱式(在范圍末尾)對應的connection.close()
調用的getConnection()
調用的計數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.