zongji icon indicating copy to clipboard operation
zongji copied to clipboard

add `subscribePosition` to options and use mysql.format

Open flarestart opened this issue 7 years ago • 4 comments

add a way to subscribe current binlog position

flarestart avatar Jul 14 '17 05:07 flarestart

Thanks for your PR, can you add some tests for this feature ?

nevill avatar Aug 13 '17 12:08 nevill

Yes, I have just add a test case for this feature, plz have a look.

flarestart avatar Aug 23 '17 07:08 flarestart

This PR is adding a new feature without explicitly stating the bug that necessitated it. In the current implementation, if a binlog event occurs that is filtered, (due to not being in the includeEvents option) there is no update to the binlogName and binlogNextPos property values.

This approach of adding another option introduces too much code to solve the problem. Instead, make those existing properties update before the filtering occurs:

if(event === undefined || event._filtered === true) return;

And then just always emit a position event, even for filtered events. The binlog_ prefix is unneeded here. Since the position and filename values are properties of the ZongJi instance object, passing these values as another object on every position update is unnecessary bloat. I recommend having no arguments for this position event. Event handlers may reference the values on the ZongJi instance.

numtel avatar Aug 23 '17 22:08 numtel

@numtel thanks for your comments, I'll check my code more carefully.

flarestart avatar Aug 24 '17 12:08 flarestart