Skip to content

Instantly share code, notes, and snippets.

View ekoeryanto's full-sized avatar

Eko Eryanto ekoeryanto

View GitHub Profile
@ekoeryanto
ekoeryanto / example.js
Created November 28, 2019 14:38 — forked from numtel/example.js
Restart ZongJi gracefully on error
var ZongJi = require('zongji');
var RETRY_TIMEOUT = 4000;
function zongjiManager(dsn, options, onBinlog) {
var newInst = new ZongJi(dsn, options);
newInst.on('error', function(reason) {
newInst.removeListener('binlog', onBinlog);
setTimeout(function() {
// If multiple errors happened, a new instance may have already been created