# `Continuum.Activity.Context`
[🔗](https://github.com/Yyeger/Continuum/blob/main/lib/continuum/activity/context.ex#L1)

Runtime context passed to activities declared with `context: true`.

Use `heartbeat/2` to persist bounded progress and `cancelled?/1` between
chunks of external work to cooperate with workflow cancellation.

# `t`

```elixir
@type t() :: %Continuum.Activity.Context{
  attempt: pos_integer(),
  instance: Continuum.Runtime.Instance.t(),
  lease_owner: binary() | nil,
  mode: :durable | :inline,
  run_id: binary(),
  task_id: binary()
}
```

# `cancelled?`

```elixir
@spec cancelled?(t()) :: boolean()
```

Returns true when the run was cancelled or this worker lost its task lease.

# `heartbeat`

```elixir
@spec heartbeat(t(), term()) :: :ok | {:error, :cancelled | :lease_lost}
```

Persists the latest progress details using the activity task's lease fence.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
