Sha256: 49214e5f0be496efcac1a476f39adac1903e7591261330503764eeafca40e5b5

Contents?: true

Size: 597 Bytes

Versions: 3

Compression:

Stored size: 597 Bytes

Contents

#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
$:.unshift File.expand_path("lib", File.dirname(__FILE__))

require "resque/picky_worker/override"

# Try not to trample on other things in redis
Resque.redis.namespace = "example:pickyworker"

# Make sure we've got some queues to choose from
Resque.redis.del "queues"
%w(1 2 3 4).each do |x|
  Resque.redis.sadd "queues", x
end

# Define how to choose a queue, we'll go for the max integer one
Resque::Worker.chooser = lambda do |queues|
  queues.map(&:to_i).select {|i| i % 2 == 0 }.max.to_s
end

Resque::Worker.pick_queue # => "4"

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
resque-picky_worker-0.0.3 example.rb
resque-picky_worker-0.0.2 example.rb
resque-picky_worker-0.0.1 example.rb