Skip to content

Golang database connection load balancer for master - slave replication

License

Notifications You must be signed in to change notification settings

RubenSchmidt/dbalancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dbalancer

Golang connection load balancer for master slave replication. It assumes a single master that can be written to and zero-to-many read replicas that can be load balanced to.

// Create a new DBalancer with the master DB
bl := dbalancer.NewDBalancer(db, rep, rep2)
defer bl.Close()

// Optional configuration for all databases
bl.SetMaxOpenConns(100)
bl.SetMaxIdleConns(50)

db := bl.ReadDB() // will balance between master, and replicas

db = bl.WriteDB() // returns master db

About

Golang database connection load balancer for master - slave replication

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages