-
Notifications
You must be signed in to change notification settings - Fork 990
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update README * Update example about GTID * Add description to examples * Add 'go mod edit' line * Remove donate and feedback sessions, add credits --------- Signed-off-by: lance6716 <[email protected]> Co-authored-by: lance6716 <[email protected]>
- Loading branch information
Showing
1 changed file
with
36 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
# go-mysql | ||
|
||
A pure go library to handle MySQL network protocol and replication. | ||
A pure go library to handle MySQL network protocol and replication as used by MySQL and MariaDB. | ||
|
||
![semver](https://img.shields.io/github/v/tag/go-mysql-org/go-mysql) | ||
![example workflow](https://github.com/go-mysql-org/go-mysql/actions/workflows/ci.yml/badge.svg) | ||
![gomod version](https://img.shields.io/github/go-mod/go-version/go-mysql-org/go-mysql/master) | ||
|
||
## How to migrate to this repo | ||
To change the used package in your repo it's enough to add this `replace` directive to your `go.mod`: | ||
``` | ||
replace github.com/siddontang/go-mysql => github.com/go-mysql-org/go-mysql v1.10.0 | ||
``` | ||
|
||
v1.10.0 - is the last tag in repo, feel free to choose what you want. | ||
[![Go Reference](https://pkg.go.dev/badge/github.com/go-mysql-org/go-mysql.svg)](https://pkg.go.dev/github.com/go-mysql-org/go-mysql) | ||
|
||
## Changelog | ||
This repo uses [Changelog](CHANGELOG.md). | ||
|
||
--- | ||
# Content | ||
* [Replication](#replication) | ||
* [Incremental dumping](#canal) | ||
* [Client](#client) | ||
* [Fake server](#server) | ||
* [database/sql like driver](#driver) | ||
* [Logging](#logging) | ||
* [Replication](#replication) - Process events from a binlog stream. | ||
* [Incremental dumping](#canal) - Sync from MySQL to Redis, Elasticsearch, etc. | ||
* [Client](#client) - Simple MySQL client. | ||
* [Fake server](#server) - server side of the MySQL protocol, as library. | ||
* [database/sql like driver](#driver) - An alternative `database/sql` driver for MySQL. | ||
* [Logging](#logging) - Custom logging options. | ||
* [Migration](#how-to-migrate-to-this-repo) - Information for how to migrate if you used the old location of this project. | ||
|
||
## Examples | ||
|
||
The `cmd` directory contains example applications that can be build by running `make build` in the root of the project. The resulting binaries will be places in `bin/`. | ||
|
||
- `go-binlogparser`: parses a binlog file at a given offset | ||
- `go-canal`: streams binlog events from a server to canal | ||
- `go-mysqlbinlog`: streams binlog events | ||
- `go-mysqldump`: like `mysqldump`, but in Go | ||
- `go-mysqlserver`: fake MySQL server | ||
|
||
## Replication | ||
|
||
|
@@ -55,9 +59,10 @@ syncer := replication.NewBinlogSyncer(cfg) | |
streamer, _ := syncer.StartSync(mysql.Position{binlogFile, binlogPos}) | ||
|
||
// or you can start a gtid replication like | ||
// gtidSet, _ := mysql.ParseGTIDSet(mysql.MySQLFlavor, "de278ad0-2106-11e4-9f8e-6edd0ca20947:1-2") | ||
// streamer, _ := syncer.StartSyncGTID(gtidSet) | ||
// the mysql GTID set likes this "de278ad0-2106-11e4-9f8e-6edd0ca20947:1-2" | ||
// the mariadb GTID set likes this "0-1-100" | ||
// the mysql GTID set is like this "de278ad0-2106-11e4-9f8e-6edd0ca20947:1-2" and uses mysql.MySQLFlavor | ||
// the mariadb GTID set is like this "0-1-100" and uses mysql.MariaDBFlavor | ||
|
||
for { | ||
ev, _ := streamer.GetEvent(context.Background()) | ||
|
@@ -111,7 +116,7 @@ Query: DROP TABLE IF EXISTS `test_replication` /* generated by server */ | |
|
||
## Canal | ||
|
||
Canal is a package that can sync your MySQL into everywhere, like Redis, Elasticsearch. | ||
Canal is a package that can sync your MySQL into everywhere, like Redis, Elasticsearch. | ||
|
||
First, canal will dump your MySQL data then sync changed data using binlog incrementally. | ||
|
||
|
@@ -161,7 +166,7 @@ func main() { | |
} | ||
``` | ||
|
||
You can see [go-mysql-elasticsearch](https://github.com/siddontang/go-mysql-elasticsearch) for how to sync MySQL data into Elasticsearch. | ||
You can see [go-mysql-elasticsearch](https://github.com/go-mysql-org/go-mysql-elasticsearch) for how to sync MySQL data into Elasticsearch. | ||
|
||
## Client | ||
|
||
|
@@ -516,17 +521,19 @@ import "github.com/siddontang/go-log/log" | |
|
||
Or you can implement your own [`log.Handler`](https://pkg.go.dev/github.com/siddontang/go-log/log#Handler). | ||
|
||
## Donate | ||
|
||
If you like the project and want to buy me a cola, you can through: | ||
|
||
|PayPal|微信| | ||
|------|---| | ||
|[![](https://www.paypalobjects.com/webstatic/paypalme/images/pp_logo_small.png)](https://paypal.me/siddontang)|[![](https://github.com/siddontang/blog/blob/master/donate/weixin.png)| | ||
## How to migrate to this repo | ||
To change the used package in your repo it's enough to add this `replace` directive to your `go.mod`: | ||
``` | ||
replace github.com/siddontang/go-mysql => github.com/go-mysql-org/go-mysql v1.10.0 | ||
``` | ||
|
||
## Feedback | ||
This can be done by running this command: | ||
``` | ||
go mod edit -replace=github.com/siddontang/go-mysql=github.com/go-mysql-org/[email protected] | ||
``` | ||
|
||
go-mysql is still in development, your feedback is very welcome. | ||
v1.10.0 - is the last tag in repo, feel free to choose what you want. | ||
|
||
## Credits | ||
|
||
Gmail: siddontang@gmail.com | ||
go-mysql was started by @siddontang and has many [contributors](https://github.com/go-mysql-org/go-mysql/graphs/contributors) |