Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/go-rel/primaryreplica
Read Write separation for primary-replica topologies
https://github.com/go-rel/primaryreplica
go hacktoberfest orm
Last synced: 8 days ago
JSON representation
Read Write separation for primary-replica topologies
- Host: GitHub
- URL: https://github.com/go-rel/primaryreplica
- Owner: go-rel
- License: mit
- Created: 2021-10-19T15:21:49.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-02T05:05:14.000Z (5 months ago)
- Last Synced: 2024-10-29T16:20:42.767Z (17 days ago)
- Topics: go, hacktoberfest, orm
- Language: Go
- Homepage:
- Size: 68.4 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# primaryreplica
[![GoDoc](https://godoc.org/github.com/go-rel/primaryreplica?status.svg)](https://pkg.go.dev/github.com/go-rel/primaryreplica)
[![Test](https://github.com/go-rel/primaryreplica/actions/workflows/test.yml/badge.svg)](https://github.com/go-rel/primaryreplica/actions/workflows/test.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-rel/primaryreplica)](https://goreportcard.com/report/github.com/go-rel/primaryreplica)
[![codecov](https://codecov.io/gh/go-rel/primaryreplica/branch/main/graph/badge.svg?token=snplQW05GK)](https://codecov.io/gh/go-rel/primaryreplica)
[![Gitter chat](https://badges.gitter.im/go-rel/rel.png)](https://gitter.im/go-rel/rel)Read Write separation for primary-replica topologies
## Example
```go
package mainimport (
"context"_ "github.com/go-sql-driver/mysql"
"github.com/go-rel/primaryreplica"
"github.com/go-rel/mysql"
"github.com/go-rel/rel"
)
func main() {
// open mysql connections.
// note: `clientFoundRows=true` is required for update and delete to works correctly.
adapter := primaryreplica.New(
mysql.MustOpen("root@(source:3306)/rel_test?charset=utf8&parseTime=True&loc=Local"),
mysql.MustOpen("root@(replica1:3306)/rel_test?charset=utf8&parseTime=True&loc=Local"),
mysql.MustOpen("root@(replica2:3306)/rel_test?charset=utf8&parseTime=True&loc=Local"),
)
defer adapter.Close()// initialize REL's repo.
repo := rel.New(adapter)
repo.Ping(context.TODO())
}
```## Load Balancing of Replicas
REL only implements a very primitive load balancing for multiple replicas.
For large scale application we recommend you to use external load balancing solution.