Class: Resque::Cluster::Config
- Inherits:
-
Object
- Object
- Resque::Cluster::Config
- Extended by:
- Forwardable
- Defined in:
- lib/resque/cluster/config.rb,
lib/resque/cluster/config/file.rb,
lib/resque/cluster/config/verifier.rb
Overview
Config is a global and local configuration of a member of a resque pool cluster
Defined Under Namespace
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#configs ⇒ Object
readonly
Returns the value of attribute configs.
-
#global_config ⇒ Object
readonly
Returns the value of attribute global_config.
-
#verifier ⇒ Object
readonly
Returns the value of attribute verifier.
Instance Method Summary collapse
- #errors ⇒ Object
- #gru_format ⇒ Object
-
#initialize(config_path, global_config_path = nil) ⇒ Config
constructor
A new instance of Config.
- #log_errors ⇒ Object
- #log_warnings ⇒ Object
- #verified? ⇒ Boolean
- #warnings ⇒ Object
Constructor Details
#initialize(config_path, global_config_path = nil) ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/resque/cluster/config.rb', line 12 def initialize(config_path, global_config_path = nil) @config = Config::File.new(config_path) @configs = [config] if global_config_path global_config = Config::File.new(global_config_path) if global_config. != config. @global_config = global_config @configs << global_config end end @errors = Set.new @verifier = Verifier.new(configs) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/resque/cluster/config.rb', line 10 def config @config end |
#configs ⇒ Object (readonly)
Returns the value of attribute configs.
10 11 12 |
# File 'lib/resque/cluster/config.rb', line 10 def configs @configs end |
#global_config ⇒ Object (readonly)
Returns the value of attribute global_config.
10 11 12 |
# File 'lib/resque/cluster/config.rb', line 10 def global_config @global_config end |
#verifier ⇒ Object (readonly)
Returns the value of attribute verifier.
10 11 12 |
# File 'lib/resque/cluster/config.rb', line 10 def verifier @verifier end |
Instance Method Details
#errors ⇒ Object
51 52 53 |
# File 'lib/resque/cluster/config.rb', line 51 def errors @errors + configs.map { |config| config.errors.map { |error| "#{config}: #{error}" } }.flatten end |
#gru_format ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/resque/cluster/config.rb', line 35 def gru_format return {} unless verified? { manage_worker_heartbeats: true, host_maximums: host_maximums, client_settings: Resque.redis.client., cluster_name: Cluster.config[:cluster_name], environment_name: Cluster.config[:environment], cluster_maximums: cluster_maximums, rebalance_flag: rebalance_flag || false, max_workers_per_host: max_workers_per_host || nil, presume_host_dead_after: presume_dead_after || 120 } end |
#log_errors ⇒ Object
65 66 67 68 69 |
# File 'lib/resque/cluster/config.rb', line 65 def log_errors errors.each do |error| puts error end end |
#log_warnings ⇒ Object
59 60 61 62 63 |
# File 'lib/resque/cluster/config.rb', line 59 def log_warnings warnings.each do |warning| puts warning end end |
#verified? ⇒ Boolean
31 32 33 |
# File 'lib/resque/cluster/config.rb', line 31 def verified? verifier.verified? && complete_worker_config? end |
#warnings ⇒ Object
55 56 57 |
# File 'lib/resque/cluster/config.rb', line 55 def warnings @warnings ||= [] end |