class HireFire::Worker
Constants
- PROCESS_NAME_PATTERN
Attributes
name[R]
Public Class Methods
new(name, &block)
click to toggle source
# File lib/hirefire/worker.rb, line 13 def initialize(name, &block) validate(name, &block) @name = name @block = block end
Public Instance Methods
value()
click to toggle source
# File lib/hirefire/worker.rb, line 19 def value @block.call end
Private Instance Methods
validate(name, &block)
click to toggle source
# File lib/hirefire/worker.rb, line 25 def validate(name, &block) unless name.to_s.match?(PROCESS_NAME_PATTERN) raise InvalidDynoNameError, "Invalid name for HireFire::Worker.new(#{name}, &block). " \ "Ensure it matches the Procfile process name (i.e. web, worker)." end unless block raise MissingDynoBlockError, "Missing block for HireFire::Worker.new(#{name}, &block). " \ "Ensure that you provide a block that returns the job queue metric." end end