zero-sqlx supports leader-follower read-write separation.
go get github.com/chenquan/zero-sqlx
- Full tracing
- Read and write separation
- Allows specified leader db execution
- Adaptive circuit breaker
- P2c algorithm
DB:
Leader: leader
Followers:
- follower1
- follower2
type Config struct{
DB DBConf
}
var c config.Config
conf.MustLoad(*configFile, &c, conf.UseEnv())
mysql := NewMultipleSqlConn("mysql", c.DB)
var name string
mysql.QueryRow(&name, "SELECT name FROM user WHERE id = 1")