Module: Bluth::Handler

Included in:
ExampleHandler
Defined in:
lib/bluth.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(obj) ⇒ Object



210
211
212
213
214
215
216
# File 'lib/bluth.rb', line 210

def self.extended(obj)
  obj.send :include, Familia
  obj.class_string :success
  obj.class_string :failure
  obj.class_string :running
  Bluth.handlers << obj
end

Instance Method Details

#allObject



257
258
259
260
261
# File 'lib/bluth.rb', line 257

def all
  Bluth::Gob.instances.select do |gob|
    gob.handler == self
  end
end

#create_job(data = {}) ⇒ Object



234
235
236
237
238
239
# File 'lib/bluth.rb', line 234

def create_job data={}
  gob = Gob.create generate_id(data), self, data
  gob.created
  gob.attempts = 0
  gob
end

#engauge(data = {}, notch = nil) ⇒ Object



224
225
226
227
228
229
230
231
232
# File 'lib/bluth.rb', line 224

def engauge(data={}, notch=nil)
  notch ||= Bluth::TimingBelt.notch 1
  gob = create_job data
  gob.notch = notch.name
  gob.save
  Familia.ld "ENNOTCHING: #{self} #{gob.jobid.short} to #{notch.rediskey}" if Familia.debug?
  notch.add gob.jobid
  gob
end

#enqueue(data = {}, q = nil) ⇒ Object



241
242
243
244
245
246
247
248
249
# File 'lib/bluth.rb', line 241

def enqueue(data={}, q=nil)
  q = self.queue(q) if q.nil? || Symbol === q
  gob = create_job data
  gob.current_queue = q.name
  gob.save
  Familia.ld "ENQUEUING: #{self} #{gob.jobid.short} to #{q}" if Familia.debug?
  q << gob.jobid
  gob
end

#generate_id(*args) ⇒ Object



254
255
256
# File 'lib/bluth.rb', line 254

def generate_id(*args)
  [self, Process.pid, Bluth.sysinfo.hostname, Time.now.to_f, *args].gibbler
end

#prepareObject



262
263
# File 'lib/bluth.rb', line 262

def prepare
end

#queue(name = nil) ⇒ Object



250
251
252
253
# File 'lib/bluth.rb', line 250

def queue(name=nil)
  @queue = name if name
  Bluth::Queue.queue(@queue || :high)
end