Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于读写分离的小问题 #8

Closed
sunxf94 opened this issue Sep 18, 2018 · 4 comments
Closed

关于读写分离的小问题 #8

sunxf94 opened this issue Sep 18, 2018 · 4 comments

Comments

@sunxf94
Copy link

sunxf94 commented Sep 18, 2018

gosql怎么支持读写分离呢,我注意到db链接是可以配置多个的,如何切换呢?

@dmskys
Copy link

dmskys commented Sep 18, 2018

@Snowin1994 gosql.Use(“dbname”)

@fifsky
Copy link
Member

fifsky commented Sep 25, 2018

目前还不支持自动读写分离,需要自行决定连接读库还是写库,比如config["master"] config["slave"] ,使用的时候

gosql.Use("slave")

@fifsky fifsky closed this as completed Sep 26, 2018
@sunxf94
Copy link
Author

sunxf94 commented Sep 28, 2018

通过 gosql.Use(“dbname”) 获取到的是一个Wrapper,之后就只能裸写sql来获取数据了?

@fifsky
Copy link
Member

fifsky commented Sep 28, 2018

通过 gosql.Use(“dbname”) 获取到的是一个Wrapper,之后就只能裸写sql来获取数据了?

如果要使用Model,这里的确是不行的,因为Model是通过结构体的Db函数得到数据库连接实例,在我们的实际项目中读写分离是mysql proxy处理的,应用层本身是不关心的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants