Skip to content

Commit 966d858

Browse files
authored
Feature/next release (#49)
- Fixed json with slash (#48) - Fixed disabling events that are needed (#46) - Changed to @inherit phpdoc in jsonSerialize methods - Removed unused exceptions from phpdoc - Changed moved wiki do readme - Changed added missing php extensions to composer.json - escape using json rpc specification
1 parent f6033e7 commit 966d858

22 files changed

+1016
-1038
lines changed

CHANGELOG.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
# Release Notes
22

3+
## v5.0.6 (2019-02-05)
4+
- Fixed json with slash (#48)
5+
- Fixed disabling events that are needed (#46)
6+
- Changed to @inherit phpdoc in jsonSerialize methods
7+
- Removed unused exceptions from phpdoc
8+
- Changed moved wiki do readme
9+
- Changed added missing php extensions to composer.json
10+
311
## v5.0.5 (2018-11-11)
4-
- Fixed support to recive more than 16Mbyte + tests
12+
- Fixed support to receive more than 16MB + tests
513

614
## v5.0.4 (2018-08-10)
7-
- Added support to recive more than 16Mbyte
15+
- Added support to receive more than 16MB
816

917
## v5.0.3 (2018-08-07)
1018
- Added symfony 4.0 compatibility in composer
1119

20+
## v5.0.3
21+
- Added symfony 4.0 compatibility in composer
22+
1223
## v5.0.2 (2018-06-22)
1324
- Added checking for eof (#42)
1425
- Added support for column type 11 - TIME (mysql 5.5 only) (#41)

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,21 @@ php example/benchmark.php
365365
8058 event by seconds (11000 total)
366366
8071 event by seconds (12000 total)
367367

368+
FAQ
369+
=========
370+
371+
1. ### Why and when need php-mysql-replication ?
372+
Well first of all mysql don't give you async calls. You usually need to program this in your application (by event dispaching and adding to some queue system and if your db have many point of entry like web, backend other microservices its not always cheap to add processing to all of them. But using mysql replication protocol you can lisen on write events and process then asynchronously (best combo it's to add item to some queue system like rabbitmq, redis or kafka).
373+
374+
2. ### It's awsome ! but what is the catch ?
375+
Well first of all you need to know that a lot of events may come through, like if you update 1 000 000 records in table "bar" and you need this one insert from your table "foo" Then all must be processed by script and you need to wait for your data. This is normal and this how it's work. You can speed up using [config options](https://github.com/krowinski/php-mysql-replication#configuration).
376+
Also if script crashes you need to save from time to time position form binlog (or gtid) to start from this position when you run this script again to avoid duplicates.
377+
378+
3. ### I need to process 1 000 000 records and its taking forever!!
379+
Like I mention in 1 point use queue system like rabbitmq, redis or kafka, they will give you ability to process data in multiple scripts.
380+
381+
4. ### I have a problem ? you script is missing something ! I have found a bug !
382+
Create an [issue](https://github.com/krowinski/php-mysql-replication/issues) I will try to workon it in my free time :)
383+
384+
5. ### How much its give overhead to mysql server ?
385+
It work like any other mysql in slave mode and its giving same overhead.

composer.json

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"require": {
1616
"php": ">=5.6",
1717
"ext-sockets": "*",
18+
"ext-json": "*",
19+
"ext-bcmath": "*",
1820
"doctrine/dbal": "^2.5",
1921
"doctrine/collections": "^1.3",
2022
"symfony/event-dispatcher": "^2.8|^3.1|^4.0",
+98-102
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,99 @@
1-
<?php
2-
3-
namespace MySQLReplication\BinLog;
4-
5-
/**
6-
* Class BinLogCurrent
7-
* @package MySQLReplication\BinLog
8-
*/
9-
class BinLogCurrent implements \JsonSerializable
10-
{
11-
/**
12-
* @var int
13-
*/
14-
private $binLogPosition;
15-
/**
16-
* @var string
17-
*/
18-
private $binFileName;
19-
/**
20-
* @var string
21-
*/
22-
private $gtid;
23-
/**
24-
* @var string
25-
*/
26-
private $mariaDbGtid;
27-
28-
/**
29-
* @return int
30-
*/
31-
public function getBinLogPosition()
32-
{
33-
return $this->binLogPosition;
34-
}
35-
36-
/**
37-
* @param int $binLogPosition
38-
*/
39-
public function setBinLogPosition($binLogPosition)
40-
{
41-
$this->binLogPosition = $binLogPosition;
42-
}
43-
44-
/**
45-
* @return string
46-
*/
47-
public function getBinFileName()
48-
{
49-
return $this->binFileName;
50-
}
51-
52-
/**
53-
* @param string $binFileName
54-
*/
55-
public function setBinFileName($binFileName)
56-
{
57-
$this->binFileName = $binFileName;
58-
}
59-
60-
/**
61-
* @return string
62-
*/
63-
public function getGtid()
64-
{
65-
return $this->gtid;
66-
}
67-
68-
/**
69-
* @param string $gtid
70-
*/
71-
public function setGtid($gtid)
72-
{
73-
$this->gtid = $gtid;
74-
}
75-
76-
/**
77-
* @return string
78-
*/
79-
public function getMariaDbGtid()
80-
{
81-
return $this->mariaDbGtid;
82-
}
83-
84-
/**
85-
* @param string $mariaDbGtid
86-
*/
87-
public function setMariaDbGtid($mariaDbGtid)
88-
{
89-
$this->mariaDbGtid = $mariaDbGtid;
90-
}
91-
92-
/**
93-
* Specify data which should be serialized to JSON
94-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
95-
* @return mixed data which can be serialized by <b>json_encode</b>,
96-
* which is a value of any type other than a resource.
97-
* @since 5.4.0
98-
*/
99-
public function jsonSerialize()
100-
{
101-
return get_object_vars($this);
102-
}
1+
<?php
2+
3+
namespace MySQLReplication\BinLog;
4+
5+
/**
6+
* Class BinLogCurrent
7+
* @package MySQLReplication\BinLog
8+
*/
9+
class BinLogCurrent implements \JsonSerializable
10+
{
11+
/**
12+
* @var int
13+
*/
14+
private $binLogPosition;
15+
/**
16+
* @var string
17+
*/
18+
private $binFileName;
19+
/**
20+
* @var string
21+
*/
22+
private $gtid;
23+
/**
24+
* @var string
25+
*/
26+
private $mariaDbGtid;
27+
28+
/**
29+
* @return int
30+
*/
31+
public function getBinLogPosition()
32+
{
33+
return $this->binLogPosition;
34+
}
35+
36+
/**
37+
* @param int $binLogPosition
38+
*/
39+
public function setBinLogPosition($binLogPosition)
40+
{
41+
$this->binLogPosition = $binLogPosition;
42+
}
43+
44+
/**
45+
* @return string
46+
*/
47+
public function getBinFileName()
48+
{
49+
return $this->binFileName;
50+
}
51+
52+
/**
53+
* @param string $binFileName
54+
*/
55+
public function setBinFileName($binFileName)
56+
{
57+
$this->binFileName = $binFileName;
58+
}
59+
60+
/**
61+
* @return string
62+
*/
63+
public function getGtid()
64+
{
65+
return $this->gtid;
66+
}
67+
68+
/**
69+
* @param string $gtid
70+
*/
71+
public function setGtid($gtid)
72+
{
73+
$this->gtid = $gtid;
74+
}
75+
76+
/**
77+
* @return string
78+
*/
79+
public function getMariaDbGtid()
80+
{
81+
return $this->mariaDbGtid;
82+
}
83+
84+
/**
85+
* @param string $mariaDbGtid
86+
*/
87+
public function setMariaDbGtid($mariaDbGtid)
88+
{
89+
$this->mariaDbGtid = $mariaDbGtid;
90+
}
91+
92+
/**
93+
* @inheritdoc
94+
*/
95+
public function jsonSerialize()
96+
{
97+
return get_object_vars($this);
98+
}
10399
}

src/MySQLReplication/Config/Config.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,7 @@ public static function getHeartbeatPeriod()
378378
}
379379

380380
/**
381-
* Specify data which should be serialized to JSON
382-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
383-
* @return mixed data which can be serialized by <b>json_encode</b>,
384-
* which is a value of any type other than a resource.
385-
* @since 5.4.0
381+
* @inheritdoc
386382
*/
387383
public function jsonSerialize()
388384
{

src/MySQLReplication/Event/DTO/FormatDescriptionEventDTO.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ public function __toString()
3636
}
3737

3838
/**
39-
* Specify data which should be serialized to JSON
40-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
41-
* @return mixed data which can be serialized by <b>json_encode</b>,
42-
* which is a value of any type other than a resource.
43-
* @since 5.4.0
39+
* @inheritdoc
4440
*/
4541
public function jsonSerialize()
4642
{

src/MySQLReplication/Event/DTO/GTIDLogDTO.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ public function __toString()
8080
}
8181

8282
/**
83-
* Specify data which should be serialized to JSON
84-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
85-
* @return mixed data which can be serialized by <b>json_encode</b>,
86-
* which is a value of any type other than a resource.
87-
* @since 5.4.0
83+
* @inheritdoc
8884
*/
8985
public function jsonSerialize()
9086
{

src/MySQLReplication/Event/DTO/HeartbeatDTO.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ public function getType()
3636
}
3737

3838
/**
39-
* Specify data which should be serialized to JSON
40-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
41-
* @return mixed data which can be serialized by <b>json_encode</b>,
42-
* which is a value of any type other than a resource.
43-
* @since 5.4.0
39+
* @inheritdoc
4440
*/
4541
public function jsonSerialize()
4642
{

src/MySQLReplication/Event/DTO/MariaDbGtidLogDTO.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ public function getType()
6565
}
6666

6767
/**
68-
* Specify data which should be serialized to JSON
69-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
70-
* @return mixed data which can be serialized by <b>json_encode</b>,
71-
* which is a value of any type other than a resource.
72-
* @since 5.4.0
68+
* @inheritdoc
7369
*/
7470
public function jsonSerialize()
7571
{

src/MySQLReplication/Event/DTO/QueryDTO.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ public function __toString()
9696
}
9797

9898
/**
99-
* Specify data which should be serialized to JSON
100-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
101-
* @return mixed data which can be serialized by <b>json_encode</b>,
102-
* which is a value of any type other than a resource.
103-
* @since 5.4.0
99+
* @inheritdoc
104100
*/
105101
public function jsonSerialize()
106102
{

src/MySQLReplication/Event/DTO/RotateDTO.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ public function __toString()
8080
}
8181

8282
/**
83-
* Specify data which should be serialized to JSON
84-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
85-
* @return mixed data which can be serialized by <b>json_encode</b>,
86-
* which is a value of any type other than a resource.
87-
* @since 5.4.0
83+
* @inheritdoc
8884
*/
8985
public function jsonSerialize()
9086
{

src/MySQLReplication/Event/DTO/RowsDTO.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ public function __toString()
8585
}
8686

8787
/**
88-
* Specify data which should be serialized to JSON
89-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
90-
* @return mixed data which can be serialized by <b>json_encode</b>,
91-
* which is a value of any type other than a resource.
92-
* @since 5.4.0
88+
* @inheritdoc
9389
*/
9490
public function jsonSerialize()
9591
{

src/MySQLReplication/Event/DTO/TableMapDTO.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ public function getType()
6060
}
6161

6262
/**
63-
* Specify data which should be serialized to JSON
64-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
65-
* @return mixed data which can be serialized by <b>json_encode</b>,
66-
* which is a value of any type other than a resource.
67-
* @since 5.4.0
63+
* @inheritdoc
6864
*/
6965
public function jsonSerialize()
7066
{

src/MySQLReplication/Event/DTO/XidDTO.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ public function __toString()
6464
}
6565

6666
/**
67-
* Specify data which should be serialized to JSON
68-
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
69-
* @return mixed data which can be serialized by <b>json_encode</b>,
70-
* which is a value of any type other than a resource.
71-
* @since 5.4.0
67+
* @inheritdoc
7268
*/
7369
public function jsonSerialize()
7470
{

0 commit comments

Comments
 (0)