Configs2026年5月23日·1 分钟阅读

Resque — Redis-Backed Background Jobs for Ruby

Mature Ruby library for creating, queuing, and processing background jobs using Redis, originally built at GitHub.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Resque Overview
通用 CLI 安装命令
npx tokrepo install 32d7f6db-56e6-11f1-9bc6-00163e2b0d79

Introduction

Resque is a Redis-backed Ruby library for creating background jobs, placing them on multiple queues, and processing them later with dedicated worker processes. Originally built at GitHub to handle tasks like repository forking, page rendering, and email delivery, it became one of the foundational tools for asynchronous processing in the Ruby ecosystem. Jobs are stored as simple JSON in Redis, making the system inspectable and debuggable.

What Resque Does

  • Queues background jobs as JSON payloads in Redis lists
  • Processes jobs with forking workers that isolate each job in a child process
  • Provides a built-in Sinatra web UI for monitoring queues, workers, and failed jobs
  • Supports multiple named queues with configurable priority ordering
  • Offers retry, scheduling, and rate-limiting through a plugin ecosystem

Architecture Overview

Resque stores each job as a JSON hash containing the class name and arguments in a Redis list keyed by queue name. Workers poll one or more queues, dequeue a job, fork a child process, and execute the job's perform class method. Forking ensures that memory leaks or crashes in a job do not affect the long-running worker process. The web dashboard reads Redis directly to display real-time queue depths, worker status, and failed job details.

Self-Hosting & Configuration

  • Add gem 'resque' to your Gemfile and run bundle install
  • Configure the Redis connection via Resque.redis = 'redis://localhost:6379'
  • Define job classes with a @queue attribute and a self.perform method
  • Start workers with QUEUE=critical,default rake resque:work
  • Mount the web UI in your Rails routes: mount Resque::Server, at: '/resque'

Key Features

  • Jobs are simple Ruby classes with no framework lock-in
  • Forking worker model provides memory isolation per job
  • Built-in web dashboard for real-time monitoring
  • JSON-based job format is easy to inspect and debug in Redis
  • Extensive plugin ecosystem for scheduling, retries, and batching

Comparison with Similar Tools

  • Sidekiq — threaded workers with higher throughput; Resque uses forking for stronger isolation
  • Delayed Job — stores jobs in the database; Resque uses Redis for speed
  • GoodJob — Postgres-backed with Active Job; Resque predates Active Job
  • Celery — Python equivalent with similar Redis/AMQP backends
  • BullMQ — Node.js queue; Resque serves the Ruby ecosystem

FAQ

Q: Should I choose Resque or Sidekiq for a new project? A: Sidekiq offers higher throughput with threads. Resque is a good fit when you need forking isolation or prefer a simpler mental model.

Q: How do I handle failed jobs? A: Resque stores failed jobs in a dedicated Redis key. The web UI lets you inspect, retry, or clear them.

Q: Can Resque work with Rails Active Job? A: Yes. Set config.active_job.queue_adapter = :resque in your Rails configuration.

Q: How do I schedule recurring jobs? A: Use the resque-scheduler gem, which adds cron-like scheduling backed by Redis.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产