Class: Pandemic::ClientSide::Config
- Inherits:
-
Object
- Object
- Pandemic::ClientSide::Config
- Defined in:
- lib/pandemic/client_side/config.rb
Constant Summary collapse
- @@load_mutex =
Mutex.new
Class Attribute Summary collapse
-
.config_path ⇒ Object
Returns the value of attribute config_path.
-
.connection_wait_timeout ⇒ Object
Returns the value of attribute connection_wait_timeout.
-
.loaded ⇒ Object
Returns the value of attribute loaded.
-
.max_connections_per_server ⇒ Object
Returns the value of attribute max_connections_per_server.
-
.min_connections_per_server ⇒ Object
Returns the value of attribute min_connections_per_server.
-
.response_timeout ⇒ Object
Returns the value of attribute response_timeout.
-
.servers ⇒ Object
Returns the value of attribute servers.
Class Method Summary collapse
Class Attribute Details
.config_path ⇒ Object
Returns the value of attribute config_path.
6 7 8 |
# File 'lib/pandemic/client_side/config.rb', line 6 def config_path @config_path end |
.connection_wait_timeout ⇒ Object
Returns the value of attribute connection_wait_timeout.
7 8 9 |
# File 'lib/pandemic/client_side/config.rb', line 7 def connection_wait_timeout @connection_wait_timeout end |
.loaded ⇒ Object
Returns the value of attribute loaded.
6 7 8 |
# File 'lib/pandemic/client_side/config.rb', line 6 def loaded @loaded end |
.max_connections_per_server ⇒ Object
Returns the value of attribute max_connections_per_server.
7 8 9 |
# File 'lib/pandemic/client_side/config.rb', line 7 def max_connections_per_server @max_connections_per_server end |
.min_connections_per_server ⇒ Object
Returns the value of attribute min_connections_per_server.
7 8 9 |
# File 'lib/pandemic/client_side/config.rb', line 7 def min_connections_per_server @min_connections_per_server end |
.response_timeout ⇒ Object
Returns the value of attribute response_timeout.
7 8 9 |
# File 'lib/pandemic/client_side/config.rb', line 7 def response_timeout @response_timeout end |
.servers ⇒ Object
Returns the value of attribute servers.
7 8 9 |
# File 'lib/pandemic/client_side/config.rb', line 7 def servers @servers end |
Class Method Details
.load ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pandemic/client_side/config.rb', line 9 def load @@load_mutex.synchronize do return if self.loaded path = config_path yaml = YAML.load_file(path) @servers = yaml['servers'] || [] # this is just so if we copy/paste from server's yml to client's yml, it will still work @servers = @servers.values if @servers.is_a?(Hash) @servers.sort! # so it's consistent across all clients @max_connections_per_server = (yaml['max_connections_per_server'] || 1).to_i @min_connections_per_server = (yaml['min_connections_per_server'] || 1).to_i @connection_wait_timeout = (yaml['connection_wait_timeout'] || 1).to_f @response_timeout = (yaml['response_timeout'] || 1).to_f self.loaded = true end end |