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.
-
#version_git_hash ⇒ Object
readonly
Returns the value of attribute version_git_hash.
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 30 |
# 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) @version_git_hash = config_version 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 |
#version_git_hash ⇒ Object (readonly)
Returns the value of attribute version_git_hash.
10 11 12 |
# File 'lib/resque/cluster/config.rb', line 10 def version_git_hash @version_git_hash end |
Instance Method Details
#errors ⇒ Object
53 54 55 |
# File 'lib/resque/cluster/config.rb', line 53 def errors @errors + configs.map { |config| config.errors.map { |error| "#{config}: #{error}" } }.flatten end |
#gru_format ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/resque/cluster/config.rb', line 36 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, version_hash: version_git_hash } end |
#log_errors ⇒ Object
67 68 69 70 71 |
# File 'lib/resque/cluster/config.rb', line 67 def log_errors errors.each do |error| puts error end end |
#log_warnings ⇒ Object
61 62 63 64 65 |
# File 'lib/resque/cluster/config.rb', line 61 def log_warnings warnings.each do |warning| puts warning end end |
#verified? ⇒ Boolean
32 33 34 |
# File 'lib/resque/cluster/config.rb', line 32 def verified? verifier.verified? && complete_worker_config? end |
#warnings ⇒ Object
57 58 59 |
# File 'lib/resque/cluster/config.rb', line 57 def warnings @warnings ||= [] end |