heartbeat: Heartbeat Loop

View source: R/heartbeat_loops.R

heartbeatR Documentation

Heartbeat Loop

Description

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.

Usage

heartbeat(
  network_id,
  config,
  worker_id,
  heartbeat_period,
  heartbeat_expire,
  pid
)

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.

Value

NULL

Examples

# This example is not executed since Redis must be installed

   config_local = redux::redis_config()

   rush_plan(
     config = config_local,
     n_workers = 2,
     lgr_thresholds = c(rush = "info"))

   rush = rsh(network_id = "test_network")

   fun = function(x1, x2, ...) list(y = x1 + x2)
   rush$start_local_workers(
     fun = fun,
     heartbeat_period = 3,
     heartbeat_expire = 9)

   rush$stop_workers()


rush documentation built on Sept. 11, 2024, 9:15 p.m.