Skip to main content

Module async_graph

Module async_graph 

Source
Expand description

Async wrappers for the knowledge graph.

All operations run on the Tokio blocking thread pool via tokio::task::spawn_blocking, keeping the async executor free.

§Usage

use std::sync::{Arc, Mutex};
use rusqlite::Connection;
use llm_kernel::graph::{init_graph_schema, GraphNode};
use llm_kernel::graph::async_graph::AsyncGraph;

let conn = Connection::open_in_memory().unwrap();
init_graph_schema(&conn).unwrap();
let graph = AsyncGraph::new(conn);

graph.upsert_node(GraphNode {
    id: "n1".into(),
    node_type: "concept".into(),
    title: "Example".into(),
    body: "body text".into(),
    tags: vec![],
    projects: vec![],
    agents: vec![],
    created: "2026-01-01T00:00:00Z".into(),
    updated: "2026-01-01T00:00:00Z".into(),
    importance: 0.5,
    access_count: 0,
    accessed_at: String::new(),
}).await.unwrap();

Structs§

AsyncGraph
Async handle to a knowledge graph backed by a rusqlite::Connection.