diff --git a/config.json b/config.json index fecad5b..7237058 100644 --- a/config.json +++ b/config.json @@ -11,7 +11,7 @@ "updaterows", "deleterows" ], - "interval": 5000, + "flushInterval": 5000, "queue": "orderRecalc", "addQuery": "INSERT INTO `hedera`.`orderRecalc` (`orderFk`) VALUES ?", "includeSchema": { diff --git a/index.js b/index.js index 563a195..aa0165b 100644 --- a/index.js +++ b/index.js @@ -65,7 +65,7 @@ async function main() { }; const [res] = await db.query( - 'SELECT `logName`, `position` FROM `util`.`asyncQueue` WHERE code = ?', + 'SELECT `logName`, `position` FROM `util`.`binlogQueue` WHERE code = ?', [config.queue] ); if (res.length) { @@ -77,7 +77,7 @@ async function main() { opts.startAtEnd = true; zongji.start(opts); - setInterval(flushQueue, config.interval); + setInterval(flushQueue, config.flushInterval); console.log('Listenig binary log events.'); process.on('SIGINT', async function() { @@ -98,7 +98,7 @@ async function flushQueue() { for (const fk of fks) ids.push([fk]); await db.query(config.addQuery, [ids]); await db.query( - 'REPLACE INTO `util`.`asyncQueue` (`code`, `logName`, `position`) VALUES (?, ?, ?)', + 'REPLACE INTO `util`.`binlogQueue` (`code`, `logName`, `position`) VALUES (?, ?, ?)', [config.queue, filename, nextPosition] ); fks.clear(); diff --git a/zongji.sql b/zongji.sql index d8ff6ec..bb6e63c 100644 --- a/zongji.sql +++ b/zongji.sql @@ -1,5 +1,5 @@ -CREATE TABLE `util`.`asyncQueue`( +CREATE TABLE `util`.`binlogQueue`( `code` VARCHAR(255) NOT NULL, `logName` VARCHAR(255) NOT NULL, `position` BIGINT UNSIGNED NOT NULL, @@ -9,5 +9,6 @@ CREATE TABLE `util`.`asyncQueue`( CREATE USER 'zongji'@'%' IDENTIFIED BY 'password'; GRANT REPLICATION SLAVE, REPLICATION CLIENT, SELECT ON *.* TO 'zongji'@'%'; -GRANT INSERT, DELETE ON `util`.`asyncQueue` TO 'zongji'@'%'; +GRANT INSERT, DELETE ON `util`.* TO 'zongji'@'%'; GRANT INSERT ON `hedera`.`orderRecalc` TO 'zongji'@'%'; +GRANT INSERT ON `vn`.`ticketRecalc` TO 'zongji'@'%'; diff --git a/zongji.undo.sql b/zongji.undo.sql index fa2f653..62e9607 100644 --- a/zongji.undo.sql +++ b/zongji.undo.sql @@ -1,3 +1,3 @@ -DROP TABLE IF EXISTS `util`.`asyncQueue`; +DROP TABLE IF EXISTS `util`.`binlogQueue`; DROP USER 'zongji'@'%';