-
Notifications
You must be signed in to change notification settings - Fork 987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update README #950
base: master
Are you sure you want to change the base?
Update README #950
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
# 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) | ||
* [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. | ||
* [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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact I don't know what's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like it might be similar, but I'm not sure it is the same or if it is compatible. |
||
- `go-mysqlbinlog`: streams binlog events | ||
- `go-mysqldump`: like `mysqldump`, but in Go | ||
- `go-mysqlserver`: fake MySQL server | ||
|
||
## Replication | ||
|
||
|
@@ -54,9 +58,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()) | ||
|
@@ -110,7 +115,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. | ||
|
||
|
@@ -160,7 +165,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 | ||
|
||
|
@@ -492,17 +497,19 @@ func main() { | |
|
||
We pass all tests in https://github.com/bradfitz/go-sql-test using go-mysql driver. :-) | ||
|
||
## 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the difference between this "Incremental dumping" and "Replication" item are developers need to implement interfaces (like
EventHandler
) or handle decoded binlog events. Maybe use "library mode" or "framework mode". I choose these two words to tell the difference likehttps://www.freecodecamp.org/news/the-difference-between-a-framework-and-a-library-bd133054023f/ (a random blog ranks top in google search "library vs framework")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you want me to change. Do you you want to clarify the difference between "Replication" and "Incremental dumping"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However I don't have confidence how to describe these two items. Will think about it later