Durable execution
Some work takes a while — a multi-step build, a long batch job. #[kiki::durable] makes that work survive restarts and device moves by checkpointing state at each await.
The macro
rust
use kiki::prelude::*;
#[kiki::durable]
async fn process_batch(&mut self, items: Vec<Item>) -> Result<Summary> {
let mut done = vec![];
for item in items {
let result = self.handle(item).await?; // checkpoint here
done.push(result);
}
Ok(summarize(done))
}Each await becomes a saved checkpoint of the function's progress. If the task's device restarts, or the session moves to another machine, execution resumes from the last checkpoint — not from the beginning.
Why it matters
This is what lets a user park a long task and pick it up later, or start it on a desktop and finish it on a server. Only the change since the last checkpoint transfers, so moving a task between machines is cheap.
When to use it
- Use it for long, multi-step work where losing progress would hurt — batch jobs, long generations, anything worth resuming mid-flight.
- Skip it for quick operations. Checkpointing has a small cost a fast tool call doesn't need.
Next: Components and Schemas.