Class: BlackStack::Pampa::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/pampa.rb

Overview

stub worker class

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_jobObject

name to identify uniquely the worker



238
239
240
# File 'lib/pampa.rb', line 238

def assigned_job
  @assigned_job
end

#attachedObject

name to identify uniquely the worker



238
239
240
# File 'lib/pampa.rb', line 238

def attached
  @attached
end

#idObject

name to identify uniquely the worker



238
239
240
# File 'lib/pampa.rb', line 238

def id
  @id
end

#nodeObject

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

#attachObject

attach worker to get dispatcher working with it



260
261
262
# File 'lib/pampa.rb', line 260

def attach()
    self.attached = true
end

#detachObject

detach worker to get dispatcher working with it



264
265
266
# File 'lib/pampa.rb', line 264

def detach()
    self.attached = false
end

#to_hashObject

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