Async::Job::Processor::RedisSourceAsyncJobProcessorRedisReadyList

class ReadyList

Manages the queue of jobs ready for immediate processing. Jobs are stored in Redis lists with FIFO (first-in, first-out) ordering.

Definitions

def initialize(client, key)

Initialize a new ready list manager.

Signature

parameter client Async::Redis::Client

The Redis client instance.

parameter key String

The Redis key for the ready job list.

Implementation

def initialize(client, key)
	@client = client
	@key = key
	
	@add = @client.script(:load, ADD)
end

attr :key

Signature

attribute String

The Redis key for this ready list.

def size

Signature

returns Integer

The number of jobs currently in the ready list.

Implementation

def size
	@client.llen(@key)
end

def add(job, job_store)

Add a new job to the ready queue.

Signature

parameter job String

The serialized job data.

parameter job_store JobStore

The job store to save the job data.

returns String

The unique job ID.

Implementation

def add(job, job_store)
	id = SecureRandom.uuid
	
	@client.evalsha(@add, 2, job_store.key, @key, id, job)
	
	return id
end