Closed saulius closed 10 years ago
This is regarding https://www.pivotaltracker.com/story/show/58300476
We cannot use https://github.com/bdurand/seamless_database_pool for master/slave database support, but Sequel has this functionality baked in. See http://sequel.rubyforge.org/rdoc/files/doc/sharding_rdoc.html#label-Master+and+Slave+Database+Configurations
So in order to make this work all we need to do is extend database.yml like so:
# config/database.yml development: adapter: mysql2 encoding: utf8 reconnect: true database: tariff_development username: tariff password: tariff servers: :read_only: :host: 'slave_host'
Mind the servers hash, this is new. Then all reads will go through slave_host:
servers
slave_host
[1] pry(main)> Commodity.first Sequel::DatabaseConnectionError: Mysql2::Error: Unknown MySQL server host 'slave_host' (25)
If there are more slave hosts we can do something similar to what Sequel guide suggests regarding DB.get_slave_host.
DB.get_slave_host
Ping @jabley @matthewford
Looks good. I've made a pull request in the deployment configuration.
merged
This is regarding https://www.pivotaltracker.com/story/show/58300476
We cannot use https://github.com/bdurand/seamless_database_pool for master/slave database support, but Sequel has this functionality baked in. See http://sequel.rubyforge.org/rdoc/files/doc/sharding_rdoc.html#label-Master+and+Slave+Database+Configurations
So in order to make this work all we need to do is extend database.yml like so:
Mind the
servers
hash, this is new. Then all reads will go throughslave_host
:If there are more slave hosts we can do something similar to what Sequel guide suggests regarding
DB.get_slave_host
.Ping @jabley @matthewford