Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

dbresolver

> 数据库
Open source

Golang Database Resolver and Wrapper for any multiple database connections topology, e.g. master-slave replication database, cross-region application, and for s

183 stars0 likes2 views
WebsiteGitHub

About

Golang Database Resolver and Wrapper for any multiple database connections topology, e.g. master-slave replication database, cross-region application, and for s

dbresolver

Golang Database Resolver and Wrapper for any multiple database connections topology, eg. master-slave replication database, cross-region application.

Idea and Inspiration

This DBResolver library will split your connections to correct defined DBs. Eg, all read query will routed to ReadOnly replica db, and all write operation(Insert, Update, Delete) will routed to Primary/Master DB.

Read More

Items Link
Blogpost blog post
Excalidraw diagram
GoSG Meetup Demo repository
GoSG Presentation deck
Instagram post

Usecase 1: Separated RW and RO Database connection

Click to Expand

  • You have your application deployed
  • Your application is heavy on read operations
  • Your DBs replicated to multiple replicas for faster queries
  • You separate the connections for optimized query

Usecase 2: Cross Region Database

Click to Expand

  • Your application deployed to multi regions.
  • You have your Databases configured globally.

Usecase 3: Multi-Master (Multi-Primary) Database

Click to Expand

  • You're using a Multi-Master database topology eg, Aurora Multi-Master

Support

You can file an Issue. See documentation in Go.Dev

Getting Started

Download

bash
go get -u github.com/bxcodec/dbresolver/v2

Example

Implementing DB Resolver using *sql.DB

Click to Expand

…

Important Notes

  • Primary Database will be used when you call these functions
    • Exec
    • ExecContext
    • Begin (transaction will use primary)
    • BeginTx
    • Queries with "RETURNING" clause
      • Query
      • QueryContext
      • QueryRow
      • QueryRowContext
  • Replica Databases will be used when you call these functions
    • Query
    • QueryContext
    • QueryRow
    • QueryRowContext

Contribution

To contrib to this project, you can open a PR or an issue.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Godatabasedatabase-replicationdbresolverglobal-database

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库