Class: BlackStack::Pampa::Worker
- Inherits:
-
Object
- Object
- BlackStack::Pampa::Worker
- Defined in:
- lib/pampa.rb
Overview
stub worker class
Instance Attribute Summary collapse
-
#assigned_job ⇒ Object
name to identify uniquely the worker.
-
#attached ⇒ Object
name to identify uniquely the worker.
-
#id ⇒ Object
name to identify uniquely the worker.
-
#node ⇒ Object
name to identify uniquely the worker.
Class Method Summary collapse
-
.descriptor_errors(h) ⇒ Object
return an array with the errors found in the description of the job.
Instance Method Summary collapse
-
#attach ⇒ Object
attach worker to get dispatcher working with it.
-
#detach ⇒ Object
detach worker to get dispatcher working with it.
-
#initialize(h) ⇒ Worker
constructor
setup dispatcher configuration here.
-
#to_hash ⇒ Object
return a hash descriptor of the worker.
Constructor Details
#initialize(h) ⇒ Worker
setup dispatcher configuration here
246 247 248 249 250 251 252 |
# File 'lib/pampa.rb', line 246 def initialize(h) errors = BlackStack::Pampa::Worker.descriptor_errors(h) raise "The worker descriptor is not valid: #{errors.uniq.join(".\n")}" if errors.length > 0 self.id = h[:id] self.assigned_job = nil self.attached = true end |
Instance Attribute Details
#assigned_job ⇒ Object
name to identify uniquely the worker
238 239 240 |
# File 'lib/pampa.rb', line 238 def assigned_job @assigned_job end |
#attached ⇒ Object
name to identify uniquely the worker
238 239 240 |
# File 'lib/pampa.rb', line 238 def attached @attached end |
#id ⇒ Object
name to identify uniquely the worker
238 239 240 |
# File 'lib/pampa.rb', line 238 def id @id end |
#node ⇒ Object
name to identify uniquely the worker
238 239 240 |
# File 'lib/pampa.rb', line 238 def node @node end |
Class Method Details
.descriptor_errors(h) ⇒ Object
return an array with the errors found in the description of the job
240 241 242 243 244 |
# File 'lib/pampa.rb', line 240 def self.descriptor_errors(h) errors = [] # TODO: Code Me! errors.uniq end |
Instance Method Details
#attach ⇒ Object
attach worker to get dispatcher working with it
260 261 262 |
# File 'lib/pampa.rb', line 260 def attach() self.attached = true end |
#detach ⇒ Object
detach worker to get dispatcher working with it
264 265 266 |
# File 'lib/pampa.rb', line 264 def detach() self.attached = false end |
#to_hash ⇒ Object
return a hash descriptor of the worker
254 255 256 257 258 |
# File 'lib/pampa.rb', line 254 def to_hash() { :id => self.id, } end |