百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

dbresolver

> 数据库
开源

Golang 数据库解析器和封装器,适用于任何多个数据库连接拓扑结构,例如主从复制数据库、跨区域应用程序以及 s

183 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

Golang 数据库解析器和封装器,适用于任何多个数据库连接拓扑结构,例如主从复制数据库、跨区域应用程序以及 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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Godatabasedatabase-replicationdbresolverglobal-database

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

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