lib/litejob/server.rb in litejob-0.2.0 vs lib/litejob/server.rb in litejob-0.2.1
- old
+ new
@@ -1,14 +1,17 @@
# frozen_string_literal: true
require "litequeue"
require "litescheduler"
+require_relative "processor"
module Litejob
# Litejob::Server is responsible for popping job payloads from the SQLite queue.
# :nocov:
class Server
+ # TODO: make queues use [["default", 1]]
+ # TODO: make queue priorities optional
def initialize(queues)
@queue = Litequeue.instance
@scheduler = Litescheduler.instance
@queues = queues
# group and order queues according to their priority
@@ -24,10 +27,10 @@
end
def pop(queue)
result = @queue.pop(queue: queue)
- return result[0] if result.length == 1
+ return result unless result.is_a?(Array)
return false if result.empty?
result
end