1 Star 1 Fork 0

zd04 / mysql_rep

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
dump_events.php 1.38 KB
Copy Edit Raw Blame History
zd04 authored 2017-05-16 23:14 . add example
<?php
namespace example;
error_reporting(E_ALL);
date_default_timezone_set('PRC');
include __DIR__ . '/vendor/autoload.php';
use MySQLReplication\Config\ConfigService;
use MySQLReplication\Event\DTO\EventDTO;
use MySQLReplication\Event\EventSubscribers;
use MySQLReplication\MySQLReplicationFactory;
$binLogStream = new MySQLReplicationFactory(
(new ConfigService())->makeConfigFromArray([
'user' => 'root',
'host' => '127.0.0.1',
'password' => '123456',
'binLogFileName' => __DIR__."/binlog.bin",
'slaveId' => 2,
//'mariaDbGtid' => '1-1-3,0-1-88',
//'gtid' => '9b1c8d18-2a76-11e5-a26b-000c2976f3f3:1-177592',
])
);
/**
* Class BenchmarkEventSubscribers
* @package example
*/
class MyEventSubscribers extends EventSubscribers
{
/**
* @param EventDTO $event (your own handler more in EventSubscribers class )
*/
public function allEvents(EventDTO $event)
{
// all events got __toString() implementation
echo $event;
// all events got JsonSerializable implementation
echo json_encode($event, JSON_PRETTY_PRINT);
echo 'Memory usage ' . round(memory_get_usage() / 1048576, 2) . ' MB' . PHP_EOL;
}
}
// register your events handler here
$binLogStream->registerSubscriber(new MyEventSubscribers());
// start consuming events
while (1) {
$binLogStream->binLogEvent();
}
PHP
1
https://gitee.com/zd04/mysql_rep.git
git@gitee.com:zd04/mysql_rep.git
zd04
mysql_rep
mysql_rep
master

Search