6
6
use MySQLReplication \BinaryDataReader \BinaryDataReader ;
7
7
use MySQLReplication \BinaryDataReader \BinaryDataReaderException ;
8
8
use MySQLReplication \BinLog \BinLogException ;
9
- use MySQLReplication \BinLog \BinLogServerInfo ;
10
9
use MySQLReplication \BinLog \BinLogSocketConnect ;
11
10
use MySQLReplication \Config \Config ;
12
11
use MySQLReplication \Definitions \ConstEventType ;
@@ -35,7 +34,6 @@ class Event
35
34
* @var Config
36
35
*/
37
36
private $ config ;
38
- private $ binLogServerInfo ;
39
37
40
38
public function __construct (
41
39
Config $ config ,
@@ -45,13 +43,17 @@ public function __construct(
45
43
CacheInterface $ cache
46
44
) {
47
45
$ this ->config = $ config ;
48
- $ this ->binLogServerInfo = $ binLogSocketConnect ->getBinLogServerInfo ();
49
46
$ this ->binLogSocketConnect = $ binLogSocketConnect ;
50
47
$ this ->rowEventFactory = $ rowEventFactory ;
51
48
$ this ->eventDispatcher = $ eventDispatcher ;
52
49
$ this ->cache = $ cache ;
53
50
}
54
51
52
+ public function connect (): void
53
+ {
54
+ $ this ->binLogSocketConnect ->connect ();
55
+ }
56
+
55
57
/**
56
58
* @throws BinaryDataReaderException
57
59
* @throws BinLogException
@@ -62,6 +64,7 @@ public function __construct(
62
64
*/
63
65
public function consume (): void
64
66
{
67
+ $ binLogServerInfo = $ this ->binLogSocketConnect ->getBinLogServerInfo ();
65
68
$ binaryDataReader = new BinaryDataReader ($ this ->binLogSocketConnect ->getResponse ());
66
69
67
70
// check EOF_Packet -> https://dev.mysql.com/doc/internals/en/packet-EOF_Packet.html
@@ -80,7 +83,7 @@ public function consume(): void
80
83
$ eventDTO = $ this ->rowEventFactory ->makeRowEvent ($ binaryDataReader , $ eventInfo )->makeTableMapDTO ();
81
84
} else if (ConstEventType::ROTATE_EVENT === $ eventInfo ->getType ()) {
82
85
$ this ->cache ->clear ();
83
- $ eventDTO = (new RotateEvent ($ this -> binLogServerInfo , $ eventInfo , $ binaryDataReader ))->makeRotateEventDTO ();
86
+ $ eventDTO = (new RotateEvent ($ binLogServerInfo , $ eventInfo , $ binaryDataReader ))->makeRotateEventDTO ();
84
87
} else if (ConstEventType::GTID_LOG_EVENT === $ eventInfo ->getType ()) {
85
88
$ eventDTO = (new GtidEvent ($ eventInfo , $ binaryDataReader ))->makeGTIDLogDTO ();
86
89
} else if (ConstEventType::HEARTBEAT_LOG_EVENT === $ eventInfo ->getType ()) {
@@ -127,7 +130,8 @@ private function createEventInfo(BinaryDataReader $binaryDataReader): EventInfo
127
130
128
131
private function filterDummyMariaDbEvents (QueryDTO $ queryDTO ): ?QueryDTO
129
132
{
130
- if ($ this ->binLogServerInfo ->isMariaDb () && false !== strpos ($ queryDTO ->getQuery (), self ::MARIADB_DUMMY_QUERY )) {
133
+ if ($ this ->binLogSocketConnect ->getBinLogServerInfo ()->isMariaDb () &&
134
+ false !== strpos ($ queryDTO ->getQuery (), self ::MARIADB_DUMMY_QUERY )) {
131
135
return null ;
132
136
}
133
137
0 commit comments