Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,054 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ pkg/* | |
.DS_STORE | ||
|
||
spec/redis.config.yml | ||
bundle | ||
spec/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rvm use 1.9.3@qless --create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Qless | ||
module JobReservers | ||
class Ordered | ||
attr_reader :queues | ||
|
||
def initialize(queues) | ||
@queues = queues | ||
end | ||
|
||
def reserve | ||
@queues.each do |q| | ||
job = q.pop | ||
return job if job | ||
end | ||
nil | ||
end | ||
|
||
def description | ||
@description ||= @queues.map(&:name).join(', ') + " (ordered)" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Qless | ||
module JobReservers | ||
class RoundRobin | ||
attr_reader :queues | ||
|
||
def initialize(queues) | ||
@queues = queues | ||
@num_queues = queues.size | ||
@last_popped_queue_index = @num_queues - 1 | ||
end | ||
|
||
def reserve | ||
@num_queues.times do |i| | ||
if job = next_queue.pop | ||
return job | ||
end | ||
end | ||
nil | ||
end | ||
|
||
def description | ||
@description ||= @queues.map(&:name).join(', ') + " (round robin)" | ||
end | ||
|
||
private | ||
|
||
def next_queue | ||
@last_popped_queue_index = (@last_popped_queue_index + 1) % @num_queues | ||
@queues[@last_popped_queue_index] | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace :qless do | ||
task :setup # no-op; users should define their own setup | ||
|
||
desc "Start a Qless worker using env vars: QUEUES, JOB_RESERVER, REDIS_URL, INTERVAL, VERBOSE, VVERBOSE" | ||
task :work => :setup do | ||
require 'qless/worker' | ||
Qless::Worker.start | ||
end | ||
end | ||
|
Oops, something went wrong.