Class: HerokuVector::Worker
- Inherits:
-
Object
- Object
- HerokuVector::Worker
- Includes:
- Helper
- Defined in:
- lib/heroku_vector/worker.rb
Instance Attribute Summary collapse
-
#dyno_scalers ⇒ Object
Returns the value of attribute dyno_scalers.
-
#engine ⇒ Object
Returns the value of attribute engine.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Worker
constructor
A new instance of Worker.
- #load_dyno_scalers ⇒ Object
- #run ⇒ Object
Methods included from Helper
Constructor Details
#initialize(options = {}) ⇒ Worker
Returns a new instance of Worker.
9 10 11 12 |
# File 'lib/heroku_vector/worker.rb', line 9 def initialize(={}) @options = @dyno_scalers = [] end |
Instance Attribute Details
#dyno_scalers ⇒ Object
Returns the value of attribute dyno_scalers.
7 8 9 |
# File 'lib/heroku_vector/worker.rb', line 7 def dyno_scalers @dyno_scalers end |
#engine ⇒ Object
Returns the value of attribute engine.
7 8 9 |
# File 'lib/heroku_vector/worker.rb', line 7 def engine @engine end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/heroku_vector/worker.rb', line 7 def @options end |
Instance Method Details
#load_dyno_scalers ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/heroku_vector/worker.rb', line 39 def load_dyno_scalers HerokuVector.dyno_scalers.each do |scaler_def| name, = scaler_def logger.info "Loading Scaler: #{name}, #{.inspect}" @dyno_scalers << DynoScaler.new(name, ) end end |
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/heroku_vector/worker.rb', line 14 def run if [:config] if File.exist?([:config]) logger.info "Loading config from '#{[:config]}'" load [:config] else logger.fatal "No config found at '#{[:config]}'" logger.info "You can copy config.rb.example => config.rb to get started" logger.info "OR run heroku_vector -c /path/to/your/config.rb" logger.info "Just Starting? Test your Source config with sampler mode: heroku_vector -s" exit 1 end end load_dyno_scalers EM.run do dyno_scalers.each do |scaler| EM::PeriodicTimer.new(scaler.period) do scaler.run end end end end |