Weave documentation
Forum

Usage with the SDK

Named local Forum wrappers with the same model recovery/concurrency limitations.

WeaveNode::open_forum(name).await creates or reuses a local named Forum store. forum_write takes owned bytes and returns an ID; forum_read and forum_take take borrowed exact-match bytes and return optional owned bytes. The SDK maps model failures into storage errors.

The example performs sequential operations during one process lifetime. SDK open does not replay previous Write/Take entries, automatically replicate tuples, or make a work claim durable across restart. The core’s mixed write/take lock-order issue still applies; the wrapper does not fix it.

use weave_sdk::prelude::*;

#[tokio::main]
async fn main() -> WeaveResult<()> {
    let node = WeaveNode::builder()
        .namespace("l1fe")
        .identifier("queue-runner")
        .storage_dir("/tmp/weave-queue")
        .build()
        .await?;

    node.open_forum("jobs").await?;

    // Producer.
    node.forum_write("jobs", b"render frame 42".to_vec()).await?;
    node.forum_write("jobs", b"render frame 43".to_vec()).await?;

    // Peek (does not consume).
    let peek = node.forum_read("jobs", b"render frame 42").await?;
    assert_eq!(peek.as_deref(), Some(b"render frame 42".as_slice()));

    // Consume.
    let taken = node.forum_take("jobs", b"render frame 42").await?;
    assert_eq!(taken.as_deref(), Some(b"render frame 42".as_slice()));

    // The second take observes this same live instance, not a restart.
    let gone = node.forum_take("jobs", b"render frame 42").await?;
    assert!(gone.is_none());

    Ok(())
}

Source declarations · SDK node declarations