durable

Attribute Macro durable 

Source
#[durable]
Expand description

Makes an async function durable by wrapping it with checkpoint-based caching.

The macro automatically:

  • Checks for existing checkpoint before execution
  • Returns cached result if checkpoint exists
  • Executes function and saves result as checkpoint if no cache

§Requirements

  • Function must be async
  • First parameter is the idempotency key (any type that implements Display)
  • Function must return Result<T, E> where T: Serialize + DeserializeOwned
  • SDK must be registered via RuntaraSdk::init() before calling

§Example

use runtara_sdk::durable;

#[durable]
pub async fn fetch_order(key: &str, order_id: &str) -> Result<Order, OrderError> {
    // The key determines caching - same key = same cached result
    db.fetch_order(order_id).await
}

// Usage:
fetch_order("order-123", "123").await