Class: HotPotato::Route::AppTask
- Inherits:
-
Object
- Object
- HotPotato::Route::AppTask
- Includes:
- Core
- Defined in:
- lib/hot_potato/dsl.rb
Constant Summary
Constants included from Core
Instance Attribute Summary collapse
-
#classname ⇒ Object
Returns the value of attribute classname.
-
#group ⇒ Object
Returns the value of attribute group.
-
#instances ⇒ Object
Returns the value of attribute instances.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #allow_group(name) ⇒ Object
-
#initialize(classname, options = {}) ⇒ AppTask
constructor
A new instance of AppTask.
- #running_instances ⇒ Object
- #type ⇒ Object
Methods included from Core
#acquire_lock, #config, #log, #queue_inject, #queue_subscribe, #release_lock, #set_logger, #stat
Constructor Details
#initialize(classname, options = {}) ⇒ AppTask
Returns a new instance of AppTask.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/hot_potato/dsl.rb', line 119 def initialize(classname, = {}) @classname = classname.to_s @instances = [:instances] || 1 @group = [:group] || "" if [:source] if [:source].class == Array @source = [:source].map { |s| s.to_s } else @source = [[:source].to_s] end else @source = nil end end |
Instance Attribute Details
#classname ⇒ Object
Returns the value of attribute classname.
118 119 120 |
# File 'lib/hot_potato/dsl.rb', line 118 def classname @classname end |
#group ⇒ Object
Returns the value of attribute group.
118 119 120 |
# File 'lib/hot_potato/dsl.rb', line 118 def group @group end |
#instances ⇒ Object
Returns the value of attribute instances.
118 119 120 |
# File 'lib/hot_potato/dsl.rb', line 118 def instances @instances end |
#source ⇒ Object
Returns the value of attribute source.
118 119 120 |
# File 'lib/hot_potato/dsl.rb', line 118 def source @source end |
Instance Method Details
#allow_group(name) ⇒ Object
134 135 136 137 |
# File 'lib/hot_potato/dsl.rb', line 134 def allow_group(name) return true if @group == "" return name == @group.to_s end |
#running_instances ⇒ Object
139 140 141 |
# File 'lib/hot_potato/dsl.rb', line 139 def running_instances stat.keys("hotpotato.apptask.*.#{classify(@classname)}.*").count || 0 end |
#type ⇒ Object
143 144 145 146 147 148 |
# File 'lib/hot_potato/dsl.rb', line 143 def type return "Faucet" if Kernel.const_get(@data[:classname]).ancestors.include?(HotPotato::Faucet) return "Worker" if Kernel.const_get(@data[:classname]).ancestors.include?(HotPotato::Worker) return "Sink" if Kernel.const_get(@data[:classname]).ancestors.include?(HotPotato::Sink) return "AppTask" end |