
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Patterns for Resque usage at TaskRabbit
work
instead of class method perform
require 'tresque'
module MyEngine
class ImageProcessor
include ::TResque::Worker
inputs :user_id, :size
def work
User.find(user_id).upload_image!(size)
end
end
end
MyEngine::ImageProcessor.enqueue(size: "small", user_id: 255)
Say what queues you process
require 'tresque'
TResque.register("account") do
queue :default, 100
queue :refresh, -5000
end
Can put workers in those queues
module Account
class RegularWorker
include ::TResque::Worker
# defaults to account_default queue
end
end
module Account
class RegularWorker
include ::TResque::Worker
queue :refresh # lower priority account_refresh queue
end
end
require 'resque/tasks'
require 'resque_scheduler/tasks'
require "resque_bus/tasks"
namespace :resque do
task :setup => [:environment] do
require 'resque_scheduler'
require 'resque/scheduler'
require 'tresque'
end
task :queues => [:setup] do
queues = ::TResque::Registry.queues
ENV["QUEUES"] = queues.join(",")
puts "TResque: #{ENV["QUEUES"]}"
end
end
Work those queues by priority
$ bundle exec rake resque:queues resque:work
TResque: account_default, account_refresh
module MyEngine
class SingletonWorker
include ::TResque::Worker
inputs :user_id
# does not enqueue another worker if this worker with same user_id waiting to be processed
queue_lock :user_id
end
end
module MyEngine
class MutexWorker
include ::TResque::Worker
inputs :user_id, :any_other_input
# does work two of these workers at the same time for the same user_id
worker_lock :user_id
end
end
Those locks are for the same worker. You can also coordinate across workers using a namespace. Or, in other words, the default namespace is the worker class name but can be overridden. The keys need the same name.
module MyEngine
class FirstWorker
include ::TResque::Worker
inputs :user_id
lock_namespace :user_calculations
worker_lock :user_id
end
class SecondWorker
include ::TResque::Worker
inputs :user_id, :other_input
lock_namespace :user_calculations
worker_lock :user_id
end
class ThirdWorker
include ::TResque::Worker
inputs :other_key
lock_namespace :user_calculations
worker_lock :user_id
def user_id
# can be a method too
User.find_by_other_key(other_key).id
end
end
end
class User < ::ActiveRecord::Base
include ::TResque::Delay
def heavy_lifting
# stuff in background
end
async :heavy_lifting, queue: 'my_queue'
def other_stuff
end
end
user = User.find(1)
# Always in the background
user.heavy_lifting
# optionally in the background
user.delay.other_stuff
Generally based on qe.
FAQs
Unknown package
We found that tresque demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.