seamless_database_pool
seamless_database_pool copied to clipboard
set master only for write operations
I want set master only for wirte operations,so i set pool_weight is zero my database.yml like this
development:
adapter: seamless_database_pool
database: mydb_development
username: read_user
password: abc123
pool_adapter: mysql2
port: 3306
master:
host: master-db.example.com
port: 6000
username: master_user
password: 567pass
pool_weight: 0
read_pool:
- host: read-db-1.example.com
pool_weight: 2
- host: read-db-2.example.com
but when i select my data list then using master not read_pool my application_controller.rb
class ApplicationController < ActionController::Base
include SeamlessDatabasePool::ControllerFilter
use_database_pool :all => :master, [:create, :update, :destroy] => :master
protect_from_forgery
end
why?? my step is error?
Your config is specifying :all => :master
which will force using the master connection. Try changing to :all => :persistent
to have the read pool be the default.
oh! I see,thank you @bdurand