Skip to main content

interrupt

Macro interrupt 

Source
macro_rules! interrupt {
    ($id:expr, $payload:expr) => { ... };
    ($payload:expr) => { ... };
}
Expand description

Interrupt macro for human-in-the-loop interactions (task-local version)

When called, execution either returns a resume value (if resuming) or sends an interrupt signal and returns an error.

This macro uses task-local storage to access the interrupt context, so it doesn’t need to be passed explicitly. The task-local must be set by the Pregel engine before spawning node tasks.

§Syntax

// Anonymous interrupt (auto-generated ID from node name + index):
interrupt!(payload)

// Named interrupt (user-specified ID for targeted resume):
interrupt!(id, payload)

§Examples

use juncture_core::interrupt;
use serde_json::json;

async fn my_node(state: MyState) -> Result<MyStateUpdate, JunctureError> {
    // Anonymous interrupt -- ID is auto-generated from node + index
    let decision: serde_json::Value = interrupt!(
        json!({"question": "Continue?", "options": ["yes", "no"]})
    )?;

    // Named interrupt -- caller can resume by ID
    let approval: serde_json::Value = interrupt!(
        "approve_step",
        json!({"question": "Approve this action?", "action": "delete"})
    )?;

    Ok(MyStateUpdate::default())
}