Skip to main content

GraphCallbackHandler

Trait GraphCallbackHandler 

Source
pub trait GraphCallbackHandler:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn on_interrupt(&self, event: &GraphInterruptEvent) { ... }
    fn on_resume(&self, event: &GraphResumeEvent) { ... }
    fn on_checkpoint_saved(&self, checkpoint_id: &str, step: usize) { ... }
    fn on_node_start(&self, node: &str, task_id: &str) { ... }
    fn on_node_end(&self, node: &str, task_id: &str, duration_ms: u64) { ... }
    fn on_node_error(&self, node: &str, error: &JunctureError) { ... }
    fn on_graph_end(&self, result: &Result<(), JunctureError>) { ... }
}
Expand description

Graph lifecycle callback trait

Implement this trait to receive notifications of important events during graph execution. All methods have default no-op implementations, so you only need to implement the events you care about.

§Examples

use juncture_tracing::callback::{GraphCallbackHandler, GraphInterruptEvent};
use juncture_core::JunctureError;
use std::sync::Arc;

struct MyCallbackHandler;

impl GraphCallbackHandler for MyCallbackHandler {
    fn on_interrupt(&self, event: &GraphInterruptEvent) {
        // Handle interrupt - e.g., log to file or send metrics
        let _ = event;
    }

    fn on_graph_end(&self, result: &Result<(), JunctureError>) {
        // Handle completion - e.g., record final status
        let _ = result;
    }
}

Provided Methods§

Source

fn on_interrupt(&self, event: &GraphInterruptEvent)

Called when the graph is interrupted

This method is invoked when a node triggers an interrupt during execution.

§Parameters
  • event - Details about the interrupt event
Source

fn on_resume(&self, event: &GraphResumeEvent)

Called when the graph resumes from an interrupt

This method is invoked when the graph continues execution after being interrupted.

§Parameters
  • event - Details about the resume event
Source

fn on_checkpoint_saved(&self, checkpoint_id: &str, step: usize)

Called when a checkpoint is saved

This method is invoked after a checkpoint is successfully persisted.

§Parameters
  • checkpoint_id - Unique identifier for the checkpoint
  • step - The step number at which this checkpoint was created
Source

fn on_node_start(&self, node: &str, task_id: &str)

Called when a node starts execution

This method is invoked when a node begins processing.

§Parameters
  • node - Name of the node starting execution
  • task_id - Unique identifier for this task instance
Source

fn on_node_end(&self, node: &str, task_id: &str, duration_ms: u64)

Called when a node completes execution

This method is invoked when a node finishes processing successfully.

§Parameters
  • node - Name of the node that completed
  • task_id - Unique identifier for this task instance
  • duration_ms - Execution duration in milliseconds
Source

fn on_node_error(&self, node: &str, error: &JunctureError)

Called when a node encounters an error

This method is invoked when a node fails during execution.

§Parameters
  • node - Name of the node that failed
  • error - The error that occurred
Source

fn on_graph_end(&self, result: &Result<(), JunctureError>)

Called when the graph execution completes

This method is invoked when the entire graph execution finishes, either successfully or with an error.

§Parameters
  • result - The final result of the graph execution

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: GraphCallbackHandler + ?Sized> GraphCallbackHandler for Arc<T>

Blanket implementation for Arc<dyn GraphCallbackHandler>

This allows Arc<dyn GraphCallbackHandler> to be used directly as a callback handler.

Source§

fn on_interrupt(&self, event: &GraphInterruptEvent)

Source§

fn on_resume(&self, event: &GraphResumeEvent)

Source§

fn on_checkpoint_saved(&self, checkpoint_id: &str, step: usize)

Source§

fn on_node_start(&self, node: &str, task_id: &str)

Source§

fn on_node_end(&self, node: &str, task_id: &str, duration_ms: u64)

Source§

fn on_node_error(&self, node: &str, error: &JunctureError)

Source§

fn on_graph_end(&self, result: &Result<(), JunctureError>)

Implementors§