| rrq_worker | R Documentation |
rrq queue worker
rrq queue worker
A rrq queue worker. These are not typically for interacting with but will sit and poll a queue for jobs.
idThe id of the worker
configThe name of the configuration used by this worker
controllerAn rrq controller object
new()Constructor
rrq_worker$new( queue_id, name_config = "localhost", worker_id = NULL, timeout_config = 0, is_child = FALSE, con = redux::hiredis(), offload_path = NULL )
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 timeout seconds.
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_child is TRUE, then most other
arguments here have no effect (e.g., queue all 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.
info()Return information about this worker, a list of key-value pairs.
rrq_worker$info()
log()Create a log entry. This will print a human readable format to screen and a machine-readable format to the redis database.
rrq_worker$log(label, value = NULL)
labelScalar character, the title of the log entry
valueCharacter vector (or null) with log values
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.
rrq_worker$load_envir()
poll()Poll for work
rrq_worker$poll(immediate = FALSE)
immediateLogical, indicating if we should not do a blocking wait on the queue but instead reducing the timeout to zero. Intended primarily for use in the tests.
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
rrq_worker$step(immediate = FALSE)
immediateLogical, indicating if we should not do a blocking wait on the queue but instead reducing the timeout to zero. Intended primarily for use in the tests.
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).
rrq_worker$loop(immediate = FALSE)
immediateLogical, indicating if we should not do a blocking wait on the queue but instead reducing the timeout to zero. Intended primarily for use in the tests.
format()Create a nice string representation of the worker. Used automatically to print the worker by R6.
rrq_worker$format()
timer_start()Start the timer
rrq_worker$timer_start()
progress()Submit a progress message. See
rrq_task_progress_update() for details of this mechanism.
rrq_worker$progress(value, error = TRUE)
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 NULL will appear
to clear the status, as NULL will also be returned if no
status is found for a task.
errorLogical, indicating if we should throw an error if
not running as an rrq task. Set this to FALSE if
you want code to work without modification within and outside of
an rrq job, or to TRUE if you want to be sure that
progress messages have made it to the server.
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
rrq_worker$task_eval(task_id)
task_idA task identifier. It is undefined what happens if this identifier does not exist.
shutdown()Stop the worker
rrq_worker$shutdown(status = "OK", graceful = TRUE)
statusthe worker status; typically be one of OK or ERROR
but can be any string
gracefulLogical, indicating if we should request a graceful shutdown of the heartbeat, if running.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.