Skip to main content

script

Attribute Macro script 

Source
#[script]
Expand description

Marks an async function as a Chronon script, enabling automatic registration and typed parameter handling.

§Requirements

  • Function must be async
  • First parameter must be Box<dyn ScriptContext>
  • Return type must be Result<()> (for example chronon_core::Result<()>)
  • name attribute is required and must be unique
  • Parameters after ScriptContext must be simple identifiers

§Examples

#[chronon::script(name = "nightly_cleanup")]
async fn nightly_cleanup(
    ctx: Box<dyn ScriptContext>,
    retention_days: u32,
) -> chronon::Result<()> {
    let _ = (ctx.label(), retention_days);
    Ok(())
}