Skip to content
Jennifer Programming Language

resque API reference

Background jobs on Redis, wire-compatible with Resque. Schedule a job onto a named queue now (enqueue), reserve and run it from a worker later (reserve). The Redis layout is the de-facto Resque standard - queues are lists at resque:queue:NAME, the queue registry is a set at resque:queues, and a job is the JSON envelope {"class":"WorkerName","args":[...]} - so a job Jennifer enqueues can be processed by a Ruby-resque / php-resque worker and vice versa. args is a list of string mapping to Ruby-resque's positional arguments; the class string is resolved on the worker's side. Built on the redis module, so it needs the default jennifer binary.

Import with import "resque.j" as resque;. See the resque guide for prose and examples.

Functions

resque.enqueue(session as redis.Session, queue as string, class as string, args as list of string)

Schedule a job: register the queue, then push the envelope onto it.

Parameters

  • session {redis.Session} - the open Redis session
  • queue {string} - the queue name to push onto
  • class {string} - the worker class the job names
  • args {list of string} - the job's positional arguments

resque.fail(session as redis.Session, job as Job, message as string)

Record a failed job on the failed list (a simplified failure entry).

Parameters

  • session {redis.Session} - the open Redis session
  • job {Job} - the job that failed
  • message {string} - the failure message

resque.queueLength(session as redis.Session, queue as string)

Return the number of pending jobs on one queue.

Parameters

  • session {redis.Session} - the open Redis session
  • queue {string} - the queue name

Returns {int} - the number of pending jobs

resque.queues(session as redis.Session)

Return the registered queue names.

Parameters

  • session {redis.Session} - the open Redis session

Returns {list of string} - the registered queue names

resque.reserve(session as redis.Session, queues as list of string)

Pop the next job from the first non-empty queue, checking queues in the given priority order.

Parameters

  • session {redis.Session} - the open Redis session
  • queues {list of string} - the queue names to check, in priority order

Returns {Job} - the reserved job, or an empty Job (class "") when all drained

resque.reserveBlocking(session as redis.Session, queues as list of string, timeoutSec as int)

Reserve the next job, BLOCKING on the given queues until one has work or timeoutSec elapses (Redis BLPOP) instead of polling with reserve. A worker loop parks on the socket rather than spinning. Queues are honoured in priority order (BLPOP returns from the first non-empty). timeoutSec 0 blocks indefinitely (Redis semantics).

Parameters

  • session {redis.Session} - the open Redis session
  • queues {list of string} - the queue names to watch, in priority order
  • timeoutSec {int} - seconds to block; 0 blocks until a job arrives

Returns {Job} - the reserved job, or an empty Job (class "") on timeout

resque.size(session as redis.Session)

Return the total number of pending jobs across every registered queue.

Parameters

  • session {redis.Session} - the open Redis session

Returns {int} - the total number of pending jobs

Structs

resque.Job

A reserved job. A drained reserve returns an empty Job (class is "").

FieldTypeDescription
queuestringthe origin queue the job came from
classstringthe worker class to run
argslist of stringthe job's positional string arguments