Skip to contents

Runs fn and saves its result under name, or returns the saved value when this task already has one. The callback runs outside any transaction, and its result is saved only once it returns, so external effects must be idempotent: lease tokens fence database writes, not other services. Give external requests stable business keys.

Usage

ca_step(task, name, fn)

Arguments

task

A claim returned by ca_claim() or passed to an R handler.

name

Stable checkpoint name.

fn

Zero-argument function returning a value supported by ca_values.

Value

The stored R value, both on initial execution and replay. Timestamps and durations have DuckDB microsecond precision. A cached NULL is distinct from an absent checkpoint.

Details

Step names must be unique within an attempt and stable across deployments, so index repeated steps in a loop. Keep saved results readable by handlers that may resume existing tasks.