The heartbeat loop updates the heartbeat key if the worker is still alive. If the kill key is set, the worker is killed. This function is called in a callr session.
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.- config
(redux::redis_config)
Redis configuration options.- worker_id
(
character(1)
)
Identifier of the worker. Keys in redis specific to the worker are prefixed with the worker id.- heartbeat_period
(
integer(1)
)
Period of the heartbeat in seconds.- heartbeat_expire
(
integer(1)
)
Time to live of the heartbeat in seconds.- pid
(
integer(1)
)
Process ID of the worker.
Examples
# This example is not executed since Redis must be installed
# \donttest{
config_local = redux::redis_config()
rush_plan(
config = config_local,
n_workers = 2,
lgr_thresholds = c(rush = "info"))
#> Error in rush_plan(config = config_local, n_workers = 2, lgr_thresholds = c(rush = "info")): Can't connect to Redis. Check the configuration.
rush = rsh(network_id = "test_network")
#> Error in initialize(...): Can't connect to Redis. Check the configuration.
fun = function(x1, x2, ...) list(y = x1 + x2)
rush$start_local_workers(
fun = fun,
heartbeat_period = 3,
heartbeat_expire = 9)
#> Error: object 'rush' not found
rush$stop_workers()
#> Error: object 'rush' not found
# }