isAlive method

bool isAlive(
  1. DateTime now,
  2. Duration timeout
)

A worker counts as alive if it hasn't signed off and its last heartbeat is within timeout of now.

Implementation

bool isAlive(DateTime now, Duration timeout) =>
    online && now.difference(lastHeartbeat) <= timeout;