Class: Litejob::Client
- Inherits:
-
Object
- Object
- Litejob::Client
- Defined in:
- lib/litejob/client.rb
Overview
Litejob::Client is responsible for pushing job payloads to the SQLite queue.
Instance Method Summary collapse
- #delete(id) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #push(jobclass, params, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/litejob/client.rb', line 9 def initialize @queue = Litequeue.instance end |
Instance Method Details
#delete(id) ⇒ Object
23 24 25 26 27 |
# File 'lib/litejob/client.rb', line 23 def delete(id) payload = @queue.delete(id) Litejob.logger.info("[litejob]:[DEL] job=#{id}") JSON.parse(payload) end |
#push(jobclass, params, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/litejob/client.rb', line 13 def push(jobclass, params, = {}) delay = [:delay] || 0 attempts = [:attempts] || 5 queue = [:queue] payload = JSON.dump({class: jobclass, params: params, attempts: attempts, queue: queue}) job_id, job_queue = atomic_push(payload, delay, queue) Litejob.logger.info("[litejob]:[ENQ] queue=#{job_queue} class=#{jobclass} job=#{job_id}") [job_id, job_queue] end |