action

Attribute Macro action 

Source
#[action]
Expand description

Marks a function as an action (side effects, external APIs).

Actions can call external APIs and perform side effects. They are NOT transactional by default but can call queries and mutations.

§Attributes

  • require_auth - Require authentication
  • require_role("admin") - Require specific role
  • timeout = 60 - Timeout in seconds

§Example

#[forge::action(timeout = 60)]
pub async fn sync_with_stripe(
    ctx: &ActionContext,
    user_id: Uuid,
) -> Result<SyncResult> {
    // Can call external APIs
    let customer = stripe::Customer::retrieve(...).await?;
    Ok(SyncResult::success())
}