Class: SlavePools::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/slave_pools/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



21
22
23
24
25
26
# File 'lib/slave_pools/config.rb', line 21

def initialize
  @environment        = 'development'
  @defaults_to_master = false
  @safe_methods       = []
  @no_replay_on_master = {}
end

Instance Attribute Details

#defaults_to_masterObject

When true, all queries will go to master unless wrapped in with_pool{}. When false, all safe queries will go to the current replica unless wrapped in with_master{}. Defaults to false.



10
11
12
# File 'lib/slave_pools/config.rb', line 10

def defaults_to_master
  @defaults_to_master
end

#environmentObject

The current environment. Normally set to Rails.env, but will default to ‘development’ outside of Rails apps.



5
6
7
# File 'lib/slave_pools/config.rb', line 5

def environment
  @environment
end

#no_replay_on_masterObject

enter a list of errors/messages that shouldn’t fall back to master of the form {‘ErrorClass’ => [‘message regex1’, ‘message regex 2’], } Defaults are => [‘Timeout waiting for a response from the last query’].



19
20
21
# File 'lib/slave_pools/config.rb', line 19

def no_replay_on_master
  @no_replay_on_master
end

#safe_methodsObject

The list of methods considered safe to send to a readonly connection. Defaults are based on Rails version.



14
15
16
# File 'lib/slave_pools/config.rb', line 14

def safe_methods
  @safe_methods
end