File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,20 @@ BinlogEvent.prototype._readTableId = function (parser) {
2828 this . tableId = Common . parseUInt48 ( parser ) ;
2929} ;
3030
31+ function Heartbeat ( parser ) {
32+ BinlogEvent . apply ( this , arguments ) ;
33+ this . binlogName = parser . parseString ( this . size - 8 ) ;
34+ this . position = Common . parseUInt64 ( parser ) ;
35+ }
36+ util . inherits ( Heartbeat , BinlogEvent ) ;
37+
38+ Heartbeat . prototype . dump = function ( ) {
39+ console . log ( '=== %s ===' , this . getTypeName ( ) ) ;
40+ console . log ( 'Event size: %d' , this . size ) ;
41+ console . log ( 'Position: %d' , this . position ) ;
42+ console . log ( 'Current binlog file: %s' , this . binlogName ) ;
43+ } ;
44+
3145/* Change MySQL bin log file
3246 * Attributes:
3347 * position: Position inside next binlog
@@ -303,6 +317,7 @@ function Unknown() {
303317util . inherits ( Unknown , BinlogEvent ) ;
304318
305319exports . BinlogEvent = BinlogEvent ;
320+ exports . Heartbeat = Heartbeat ;
306321exports . Rotate = Rotate ;
307322exports . Format = Format ;
308323exports . Query = Query ;
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ const EventClass = {
4848 FORMAT_DESCRIPTION_EVENT : events . Format ,
4949 XID_EVENT : events . Xid ,
5050 GTID_LOG_EVENT : events . GtidLog ,
51+ HEARTBEAT_LOG_EVENT : events . Heartbeat ,
5152
5253 TABLE_MAP_EVENT : events . TableMap ,
5354 DELETE_ROWS_EVENT_V1 : rowsEvents . DeleteRows ,
Original file line number Diff line number Diff line change @@ -106,6 +106,11 @@ export type BaseBinLogEvent = {
106106 useChecksum : boolean ;
107107} ;
108108
109+ export type BinLogHeartbeatEvent = {
110+ binlogName : string ;
111+ position : number ;
112+ } ;
113+
109114export type BinLogRotationEvent = BaseBinLogEvent & {
110115 binlogName : string ;
111116 position : number ;
@@ -165,6 +170,7 @@ export type BinLogQueryEvent = BaseBinLogEvent & {
165170
166171export type BinLogEvent =
167172 | BinLogRotationEvent
173+ | BinLogHeartbeatEvent
168174 | BinLogGTIDLogEvent
169175 | BinLogXidEvent
170176 | BinLogRowEvent
You can’t perform that action at this time.
0 commit comments