mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 07:16:01 +00:00
ms sql analyse - table list
This commit is contained in:
37
api/src/proc/databaseConnectionProcess.js
Normal file
37
api/src/proc/databaseConnectionProcess.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const engines = require('../engines');
|
||||
|
||||
let systemConnection;
|
||||
let storedConnection;
|
||||
|
||||
async function handleFullRefresh() {
|
||||
const driver = engines(storedConnection);
|
||||
const structure = await driver.analyseFull(systemConnection);
|
||||
console.log('SENDING STRUCTURE', structure);
|
||||
process.send({ msgtype: 'structure', structure });
|
||||
}
|
||||
|
||||
async function handleConnect(connection, database) {
|
||||
storedConnection = connection;
|
||||
|
||||
const driver = engines(storedConnection);
|
||||
systemConnection = await driver.connect({ ...storedConnection, database });
|
||||
handleFullRefresh();
|
||||
setInterval(handleFullRefresh, 30 * 1000);
|
||||
}
|
||||
|
||||
const messageHandlers = {
|
||||
connect: handleConnect,
|
||||
};
|
||||
|
||||
async function handleMessage({ msgtype, database, ...other }) {
|
||||
const handler = messageHandlers[msgtype];
|
||||
await handler(other, database);
|
||||
}
|
||||
|
||||
process.on('message', async message => {
|
||||
try {
|
||||
await handleMessage(message);
|
||||
} catch (e) {
|
||||
process.send({ msgtype: 'error', error: e.message });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user