Skip to contents

Starts a worker. The function loads the globals and packages, initializes the RushWorker instance and invokes the worker loop. This function is called by $start_local_workers() or by the user after creating the worker script with $create_worker_script(). Use with caution. The global environment is changed.

Usage

start_worker(network_id, worker_id = NULL, remote = TRUE, ...)

Arguments

network_id

(character(1))
Identifier of the rush network. Controller and workers must have the same instance id. Keys in Redis are prefixed with the instance id.

worker_id

(character(1))
Identifier of the worker. Keys in redis specific to the worker are prefixed with the worker id.

remote

(logical(1))
Whether the worker is on a remote machine.

...

(any)
Arguments passed to redux::redis_config.

Value

NULL

Note

The function initializes the connection to the Redis data base. It loads the packages and copies the globals to the global environment of the worker. The function initialize the RushWorker instance and starts the worker loop.

Examples

# This example is not executed since Redis must be installed
if (FALSE) { # \dontrun{
  rush::start_worker(
   network_id = 'test-rush',
   remote = TRUE,
   url = 'redis://127.0.0.1:6379',
   scheme = 'redis',
   host = '127.0.0.1',
   port = '6379')
} # }