Closed LoveEachDay closed 6 years ago
This is good. I am going to test this PR & report back the results.
We can debug log add current slave nodes, example:
=> User.first
[master] User Load ****
=> Slavery.on_slave { User.first }
[slave] User Load ****
=> Slavery.on_slave(:slave_foo) { User.first }
[slave_foo] User Load ****
Will be better.
What I'm not sure at this moment is if we should take everything after development_(xxx)
.
Because we already have a convention of _slave
suffix, adding more suffix rather than replacing it seems more sensible. So:
development:
database: development_master
development_slave:
database: development_slave_1
development_slave_foo:
database: development_slave_2
Should work as:
User.on_slave.count #=> perform query on development_slave_1
User.on_slave(:foo).count #=> perform query on development_slave_2
That way, we won't pollute the root-level name space and fairly safely reserve ours.
@kenn How are we looking on getting this merged? Any help we can provide to get this finalized? It seems the latest commit on this PR addressed your concern about pollution.
@kenn understood the difference you are asking for wrt on_slave(:foo)
vs on_slave(:slave_foo)
. @LoveEachDay would you like to make this change? or do you mind if we work on top of this?
@asanghi It's very nice of you to make this change. I've been busy with something else recently.
With the following config:
You make the following request: