Skip to content

Commit

Permalink
Feature/next release (#49)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
krowinski committed Feb 6, 2019
1 parent f6033e7 commit 966d858
Show file tree
Hide file tree
Showing 22 changed files with 1,016 additions and 1,038 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
@@ -1,14 +1,25 @@
# Release Notes

## v5.0.6 (2019-02-05)
- 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

## v5.0.5 (2018-11-11)
- Fixed support to recive more than 16Mbyte + tests
- Fixed support to receive more than 16MB + tests

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

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

## v5.0.3
- Added symfony 4.0 compatibility in composer

## v5.0.2 (2018-06-22)
- Added checking for eof (#42)
- Added support for column type 11 - TIME (mysql 5.5 only) (#41)
Expand Down
18 changes: 18 additions & 0 deletions README.md
Expand Up @@ -365,3 +365,21 @@ php example/benchmark.php
8058 event by seconds (11000 total)
8071 event by seconds (12000 total)

FAQ
=========

1. ### Why and when need php-mysql-replication ?
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).

2. ### It's awsome ! but what is the catch ?
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).
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.

3. ### I need to process 1 000 000 records and its taking forever!!
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.

4. ### I have a problem ? you script is missing something ! I have found a bug !
Create an [issue](https://github.com/krowinski/php-mysql-replication/issues) I will try to workon it in my free time :)

5. ### How much its give overhead to mysql server ?
It work like any other mysql in slave mode and its giving same overhead.
2 changes: 2 additions & 0 deletions composer.json
Expand Up @@ -15,6 +15,8 @@
"require": {
"php": ">=5.6",
"ext-sockets": "*",
"ext-json": "*",
"ext-bcmath": "*",
"doctrine/dbal": "^2.5",
"doctrine/collections": "^1.3",
"symfony/event-dispatcher": "^2.8|^3.1|^4.0",
Expand Down
200 changes: 98 additions & 102 deletions src/MySQLReplication/BinLog/BinLogCurrent.php
@@ -1,103 +1,99 @@
<?php

namespace MySQLReplication\BinLog;

/**
* Class BinLogCurrent
* @package MySQLReplication\BinLog
*/
class BinLogCurrent implements \JsonSerializable
{
/**
* @var int
*/
private $binLogPosition;
/**
* @var string
*/
private $binFileName;
/**
* @var string
*/
private $gtid;
/**
* @var string
*/
private $mariaDbGtid;

/**
* @return int
*/
public function getBinLogPosition()
{
return $this->binLogPosition;
}

/**
* @param int $binLogPosition
*/
public function setBinLogPosition($binLogPosition)
{
$this->binLogPosition = $binLogPosition;
}

/**
* @return string
*/
public function getBinFileName()
{
return $this->binFileName;
}

/**
* @param string $binFileName
*/
public function setBinFileName($binFileName)
{
$this->binFileName = $binFileName;
}

/**
* @return string
*/
public function getGtid()
{
return $this->gtid;
}

/**
* @param string $gtid
*/
public function setGtid($gtid)
{
$this->gtid = $gtid;
}

/**
* @return string
*/
public function getMariaDbGtid()
{
return $this->mariaDbGtid;
}

/**
* @param string $mariaDbGtid
*/
public function setMariaDbGtid($mariaDbGtid)
{
$this->mariaDbGtid = $mariaDbGtid;
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
*/
public function jsonSerialize()
{
return get_object_vars($this);
}
<?php

namespace MySQLReplication\BinLog;

/**
* Class BinLogCurrent
* @package MySQLReplication\BinLog
*/
class BinLogCurrent implements \JsonSerializable
{
/**
* @var int
*/
private $binLogPosition;
/**
* @var string
*/
private $binFileName;
/**
* @var string
*/
private $gtid;
/**
* @var string
*/
private $mariaDbGtid;

/**
* @return int
*/
public function getBinLogPosition()
{
return $this->binLogPosition;
}

/**
* @param int $binLogPosition
*/
public function setBinLogPosition($binLogPosition)
{
$this->binLogPosition = $binLogPosition;
}

/**
* @return string
*/
public function getBinFileName()
{
return $this->binFileName;
}

/**
* @param string $binFileName
*/
public function setBinFileName($binFileName)
{
$this->binFileName = $binFileName;
}

/**
* @return string
*/
public function getGtid()
{
return $this->gtid;
}

/**
* @param string $gtid
*/
public function setGtid($gtid)
{
$this->gtid = $gtid;
}

/**
* @return string
*/
public function getMariaDbGtid()
{
return $this->mariaDbGtid;
}

/**
* @param string $mariaDbGtid
*/
public function setMariaDbGtid($mariaDbGtid)
{
$this->mariaDbGtid = $mariaDbGtid;
}

/**
* @inheritdoc
*/
public function jsonSerialize()
{
return get_object_vars($this);
}
}
6 changes: 1 addition & 5 deletions src/MySQLReplication/Config/Config.php
Expand Up @@ -378,11 +378,7 @@ public static function getHeartbeatPeriod()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
* @inheritdoc
*/
public function jsonSerialize()
{
Expand Down
6 changes: 1 addition & 5 deletions src/MySQLReplication/Event/DTO/FormatDescriptionEventDTO.php
Expand Up @@ -36,11 +36,7 @@ public function __toString()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
* @inheritdoc
*/
public function jsonSerialize()
{
Expand Down
6 changes: 1 addition & 5 deletions src/MySQLReplication/Event/DTO/GTIDLogDTO.php
Expand Up @@ -80,11 +80,7 @@ public function __toString()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
* @inheritdoc
*/
public function jsonSerialize()
{
Expand Down
6 changes: 1 addition & 5 deletions src/MySQLReplication/Event/DTO/HeartbeatDTO.php
Expand Up @@ -36,11 +36,7 @@ public function getType()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
* @inheritdoc
*/
public function jsonSerialize()
{
Expand Down
6 changes: 1 addition & 5 deletions src/MySQLReplication/Event/DTO/MariaDbGtidLogDTO.php
Expand Up @@ -65,11 +65,7 @@ public function getType()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
* @inheritdoc
*/
public function jsonSerialize()
{
Expand Down
6 changes: 1 addition & 5 deletions src/MySQLReplication/Event/DTO/QueryDTO.php
Expand Up @@ -96,11 +96,7 @@ public function __toString()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
* @inheritdoc
*/
public function jsonSerialize()
{
Expand Down
6 changes: 1 addition & 5 deletions src/MySQLReplication/Event/DTO/RotateDTO.php
Expand Up @@ -80,11 +80,7 @@ public function __toString()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
* @inheritdoc
*/
public function jsonSerialize()
{
Expand Down
6 changes: 1 addition & 5 deletions src/MySQLReplication/Event/DTO/RowsDTO.php
Expand Up @@ -85,11 +85,7 @@ public function __toString()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
* @inheritdoc
*/
public function jsonSerialize()
{
Expand Down
6 changes: 1 addition & 5 deletions src/MySQLReplication/Event/DTO/TableMapDTO.php
Expand Up @@ -60,11 +60,7 @@ public function getType()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
* @inheritdoc
*/
public function jsonSerialize()
{
Expand Down
6 changes: 1 addition & 5 deletions src/MySQLReplication/Event/DTO/XidDTO.php
Expand Up @@ -64,11 +64,7 @@ public function __toString()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
* @inheritdoc
*/
public function jsonSerialize()
{
Expand Down

0 comments on commit 966d858

Please sign in to comment.