-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add an option to distribute reads among all nodes #3
Conversation
Hello @o1egl As your PR shows up, additional option targets the case that we could query to one of masters or one of slaves. The balancer only picks one that succeed. Is it your purpose? |
@linxGnu I added a description |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have small comments for your PR. Most of comments are naming only (naming is hard)
Thank you @o1egl
// ConnectMasterSlaves to master-slave databases, healthchecks will ensure they are working | ||
// driverName: mysql, postgres, etc. | ||
// masterDSNs: data source names of Masters. | ||
// slaveDSNs: data source names of Slaves. | ||
// args: args[0] = true to indicates galera/wsrep cluster. | ||
func ConnectMasterSlaves(driverName string, masterDSNs []string, slaveDSNs []string, args ...interface{}) (*DBs, []error) { | ||
func ConnectMasterSlaves(driverName string, masterDSNs []string, slaveDSNs []string, options ...Option) (*DBs, []error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love currying options like these. Thank you!
21252c8
to
7db7567
Compare
@linxGnu thank you for your review. I addressed your comments. |
@o1egl Thank you very much for your contribution. It's great to see the PR. |
In my current setup I have 1 master and 1 slave with 90% of read operations and 10% of write operations. This means that the resources of the host are not being used properly. The idea is to have and option to distribute read requests between the master and slave.