# orca.heartbeat

> A module of Orca's API.

A run's heartbeat, kept fresh from a thread while the run's steps work.

Steps run on the main thread and can take minutes, so the heartbeat can't
wait for the next attempt to be recorded. Started as
`TypedPool.start[beat](1, b)` with a `Beat`, one thread opens a connection
of its own and updates `runs.heartbeat` every `b.interval` seconds until the
pool is shut down, which joins it. A failed update is retried on the next beat: a run whose
heartbeat goes stale can be resumed elsewhere, and this process then finds
out at its next attempt (see `orca.state`).

## Structs

### `Beat`

```mojo
struct Beat
```

What the heartbeat thread needs.

Implements: `Movable`

Fields:

- `url: String`
- `run: Int`
- `owner: String`
- `interval: Float64`

#### `__init__`

```mojo
def __init__(out self, url: String, run: Int, owner: String, interval: Float64)
```

## Functions

### `beat`

```mojo
def beat(worker: Int, mut b: Beat, stop: AtomicFlag)
```

### `heartbeat_interval`

```mojo
def heartbeat_interval(stale_seconds: Float64) -> Float64
```

Five beats per stale limit, so a few missed ones don't lose the run.
