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

set master only for write operations #24

Open
clarkyi opened this issue Jul 15, 2015 · 2 comments
Open

set master only for write operations #24

clarkyi opened this issue Jul 15, 2015 · 2 comments

Comments

@clarkyi
Copy link

clarkyi commented Jul 15, 2015

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?

@bdurand
Copy link
Owner

bdurand commented Jul 15, 2015

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.

@clarkyi
Copy link
Author

clarkyi commented Jul 15, 2015

oh! I see,thank you @bdurand

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

2 participants