mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 01:55:59 +00:00
messages from query
This commit is contained in:
@@ -9,23 +9,44 @@ module.exports = {
|
||||
/** @type {import('@dbgate/types').OpenedSession[]} */
|
||||
opened: [],
|
||||
|
||||
handle_error(sesid, props) {
|
||||
const { error } = props;
|
||||
console.log(`Error in database session ${sesid}: ${error}`);
|
||||
},
|
||||
// handle_error(sesid, props) {
|
||||
// const { error } = props;
|
||||
// console.log(`Error in database session ${sesid}`, error);
|
||||
// this.dispatchMessage(sesid, {
|
||||
// severity: 'error',
|
||||
// message: error && error.toString(),
|
||||
// });
|
||||
// },
|
||||
|
||||
// handle_row(sesid, props) {
|
||||
// const { row } = props;
|
||||
// socket.emit('sessionRow', row);
|
||||
// },
|
||||
dispatchMessage(sesid, message) {
|
||||
if (_.isString(message)) {
|
||||
socket.emit(`session-info-${sesid}`, {
|
||||
message,
|
||||
time: new Date(),
|
||||
severity: 'info',
|
||||
});
|
||||
}
|
||||
if (_.isPlainObject(message)) {
|
||||
socket.emit(`session-info-${sesid}`, {
|
||||
time: new Date(),
|
||||
severity: 'info',
|
||||
...message,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
handle_info(sesid, props) {
|
||||
const { info } = props;
|
||||
socket.emit(`session-info-${sesid}`, info);
|
||||
this.dispatchMessage(sesid, info);
|
||||
},
|
||||
|
||||
handle_done(sesid) {
|
||||
socket.emit(`session-done-${sesid}`);
|
||||
this.dispatchMessage(sesid, 'Query execution finished');
|
||||
},
|
||||
|
||||
handle_recordset(sesid, props) {
|
||||
@@ -62,6 +83,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
console.log(`Processing query, sesid=${sesid}, sql=${sql}`);
|
||||
this.dispatchMessage(sesid, 'Query execution started');
|
||||
session.subprocess.send({ msgtype: 'executeQuery', sql });
|
||||
|
||||
return { state: 'ok' };
|
||||
|
||||
@@ -14,7 +14,7 @@ class StreamHandler {
|
||||
constructor() {
|
||||
this.recordset = this.recordset.bind(this);
|
||||
this.row = this.row.bind(this);
|
||||
this.error = this.error.bind(this);
|
||||
// this.error = this.error.bind(this);
|
||||
this.done = this.done.bind(this);
|
||||
this.info = this.info.bind(this);
|
||||
}
|
||||
@@ -38,9 +38,9 @@ class StreamHandler {
|
||||
// console.log('ACCEPT ROW', row);
|
||||
this.currentStream.write(JSON.stringify(row) + '\n');
|
||||
}
|
||||
error(error) {
|
||||
process.send({ msgtype: 'error', error });
|
||||
}
|
||||
// error(error) {
|
||||
// process.send({ msgtype: 'error', error });
|
||||
// }
|
||||
done(result) {
|
||||
this.closeCurrentStream();
|
||||
process.send({ msgtype: 'done', result });
|
||||
@@ -91,7 +91,14 @@ function start() {
|
||||
try {
|
||||
await handleMessage(message);
|
||||
} catch (e) {
|
||||
process.send({ msgtype: 'error', error: e.message });
|
||||
process.send({
|
||||
msgtype: 'info',
|
||||
info: {
|
||||
message: e.message,
|
||||
severity: 'error',
|
||||
},
|
||||
});
|
||||
//process.send({ msgtype: 'error', error: e.message });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user