Class: QPush::Server::Delay
- Inherits:
-
Object
- Object
- QPush::Server::Delay
- 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
-
#initialize ⇒ Delay
constructor
A new instance of Delay.
-
#shutdown ⇒ Object
Shutsdown our delay process.
-
#start ⇒ Object
Starts our delay process.
Constructor Details
#initialize ⇒ Delay
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
#shutdown ⇒ Object
Shutsdown our delay process.
27 28 29 |
# File 'lib/qpush/server/delay.rb', line 27 def shutdown @done = true end |
#start ⇒ Object
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 Server.redis do |conn| @conn = conn watch_delay { retrieve_delays } end sleep 2 end end |