rrq queue worker
rrq queue worker
Details
A rrq queue worker. These are not typically for interacting with but will sit and poll a queue for jobs.
Public fields
idThe id of the worker
configThe name of the configuration used by this worker
controllerAn rrq controller object
Methods
Method new()
Constructor
Usage
rrq_worker$new(
queue_id,
name_config = "localhost",
worker_id = NULL,
timeout_config = 0,
is_child = FALSE,
con = redux::hiredis(),
offload_path = NULL
)Arguments
queue_idThe queue id
name_configOptional name of the configuration. The default "localhost" configuration always exists. Create new configurations using rrq_worker_config_save.
worker_idOptional worker id. If omitted, a random id will be created.
timeout_configHow long to try and read the worker configuration for. Will attempt to read once a second and throw an error if config cannot be located after
timeoutseconds. Use this to create workers before their configurations are available. The default (0) is to assume that the configuration is immediately available.is_childLogical, used to indicate that this is a child of the real worker. If
is_childisTRUE, then most other arguments here have no effect (e.g.,queueall the timeout / idle / polling arguments) as they come from the parent. Not for general use.conA redis connection
offload_pathThe path to create an offload store at. See rrq_controller for details.
Method log()
Create a log entry. This will print a human readable format to screen and a machine-readable format to the redis database.
Method load_envir()
Load the worker environment by creating a new
environment object and running the create hook (if configured).
See rrq_worker_envir_set() for details.
Method step()
Take a single "step". This consists of
Poll for work (
$poll())If work found, run it (either a task or a message)
If work not found, check the timeout
Method loop()
The main worker loop. Use this to set up the main worker event loop, which will continue until exiting (via a timeout or message).
Method format()
Create a nice string representation of the worker. Used automatically to print the worker by R6.
Method progress()
Submit a progress message. See
rrq_task_progress_update() for details of this mechanism.
Arguments
valueAn R object with the contents of the update. This will overwrite any previous progress value, and can be retrieved with rrq_task_progress. A value of
NULLwill appear to clear the status, asNULLwill also be returned if no status is found for a task.errorLogical, indicating if we should throw an error if not running as an
rrqtask. Set this toFALSEif you want code to work without modification within and outside of anrrqjob, or toTRUEif you want to be sure that progress messages have made it to the server.
Method task_eval()
Evaluate a task. When running a task on a separate
process, we will always set two environment variables:
* RRQ_WORKER_ID this is the id field
* RRQ_TASK_ID this is the task id