Class: QPush::Server::Delay

Inherits:
Object
  • Object
show all
Defined in:
lib/qpush/server/delay.rb

Overview

The Delay worker requeues any jobs that have been delayed on our Redis server. Delayed jobs are pulled by a ‘zrangebyscore’, with the score representing the time the job should be performed.

Instance Method Summary collapse

Constructor Details

#initializeDelay

Returns a new instance of Delay.



8
9
10
11
# File 'lib/qpush/server/delay.rb', line 8

def initialize
  @done = false
  @conn = nil
end

Instance Method Details

#shutdownObject

Shutsdown our delay process.



27
28
29
# File 'lib/qpush/server/delay.rb', line 27

def shutdown
  @done = true
end

#startObject

Starts our delay process. This will run until instructed to stop.



15
16
17
18
19
20
21
22
23
# File 'lib/qpush/server/delay.rb', line 15

def start
  until @done
    QPush.redis.with do |conn|
      @conn = conn
      watch_delay { retrieve_delays }
    end
    sleep 2
  end
end