class QPush::Server::Queue
The Queue
worker takes any jobs that are queued into our Redis server, and moves them to the appropriate list within Redis. It will perform a 'blocking pop' on our queue list until one is added.
Public Class Methods
new()
click to toggle source
# File lib/qpush/server/queue.rb, line 8 def initialize @done = false end
Public Instance Methods
shutdown()
click to toggle source
Shutsdown our queue process.
# File lib/qpush/server/queue.rb, line 23 def shutdown @done = true end
start()
click to toggle source
Starts our queue process. This will run until instructed to stop.
# File lib/qpush/server/queue.rb, line 14 def start until @done job = retrieve_job job.setup if job end end
Private Instance Methods
retrieve_job()
click to toggle source
Performs a 'blocking pop' on our redis job list.
# File lib/qpush/server/queue.rb, line 31 def retrieve_job json = Server.redis { |c| c.brpop(Server.keys[:queue]) } Job.new(JSON.parse(json.last)) rescue => e raise ServerError, e.message end