Class: EQ::Queueing::Queue

Inherits:
Object
  • Object
show all
Extended by:
SingleForwardable
Includes:
Celluloid, Logging
Defined in:
lib/eq-queueing/queue.rb

Overview

this class basically provides a API that wraps the low-level calls to the queueing backend that is configured and passed to the #initialize method furthermore this class adds some functionality to serialize / deserialze using the Job class

Instance Method Summary collapse

Methods included from Logging

#debug, #info, #log_error

Constructor Details

#initialize(queue_backend) ⇒ Queue

Returns a new instance of Queue.

Parameters:

  • queue_backend (Object)


14
15
16
# File 'lib/eq-queueing/queue.rb', line 14

def initialize queue_backend
  @queue = queue_backend
end

Instance Method Details

#clearObject



52
53
54
# File 'lib/eq-queueing/queue.rb', line 52

def clear
  queue.clear
end

#count(name = nil) ⇒ Object



46
# File 'lib/eq-queueing/queue.rb', line 46

def count name=nil; queue.count name; end

#iterator(&block) ⇒ Object



48
49
50
# File 'lib/eq-queueing/queue.rb', line 48

def iterator &block
  queue.iterator &block
end

#jobsObject



43
# File 'lib/eq-queueing/queue.rb', line 43

def jobs; queue.jobs; end

#pop(*args) ⇒ Object

TODO #pop method: shall we add a check, when the job is worked on, if we are the worker?



37
38
39
# File 'lib/eq-queueing/queue.rb', line 37

def pop *args
  queue.pop *args
end

#push(job_class, *job_payload) ⇒ Fixnum

Returns job_id.

Parameters:

  • unserialized_payload (Array<Class, *payload>)

Returns:

  • (Fixnum)

    job_id



20
21
22
23
# File 'lib/eq-queueing/queue.rb', line 20

def push job_class, *job_payload
  debug "enqueing #{job_payload.inspect} ..."
  queue.push EQ::Job.new(nil, job_class, job_payload)
end

#requeue_timed_out_jobsObject



41
# File 'lib/eq-queueing/queue.rb', line 41

def requeue_timed_out_jobs; queue.requeue_timed_out_jobs; end

#reserveEQ::Job, nilClass

Returns job instance.

Returns:

  • (EQ::Job, nilClass)

    job instance



26
27
28
29
30
31
32
# File 'lib/eq-queueing/queue.rb', line 26

def reserve
  requeue_timed_out_jobs
  if job = queue.reserve
    debug "dequeud #{job.inspect}"
    job
  end
end

#waitingObject



45
# File 'lib/eq-queueing/queue.rb', line 45

def waiting; queue.waiting; end

#workingObject



44
# File 'lib/eq-queueing/queue.rb', line 44

def working; queue.working; end