Skip to main content

GraphLifecycleCallback

Trait GraphLifecycleCallback 

Source
pub trait GraphLifecycleCallback:
    Send
    + Sync
    + 'static {
    // Provided methods
    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>) { ... }
    fn on_checkpoint_saved(&self, checkpoint_id: &str, step: usize) { ... }
}
Expand description

Callback trait for graph lifecycle events.

Implementations receive notifications at key points during graph execution. All methods have default no-op implementations. Injected via RunnableConfig::with_callback_handler.

The trait lives in juncture-core so the Pregel engine can emit callbacks without depending on juncture-tracing. The juncture-tracing crate provides a blanket impl that forwards GraphCallbackHandler to this trait, so any type implementing GraphCallbackHandler can be passed to RunnableConfig::with_callback_handler directly.

§Examples

use std::sync::Arc;
use juncture_core::observability::GraphLifecycleCallback;
use juncture_core::config::RunnableConfig;

let handler: Arc<dyn GraphLifecycleCallback> = /* ... */;
let config = RunnableConfig::new()
    .with_callback_handler(handler);

Provided Methods§

Source

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

Called when a node starts execution.

Source

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

Called when a node completes execution successfully.

Source

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

Called when a node encounters an error.

Source

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

Called when the graph execution completes.

Source

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

Called when a checkpoint is saved.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§