Crate tana_event_bus

Crate tana_event_bus 

Source
Expand description

Tana Event Bus - Rust Client Library

This library provides a simple interface for dispatching events to the Tana Event Bus server.

§Examples

use tana_event_bus::{dispatch_event, Event, EventLevel, configure};
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Optional: Configure once at app startup
    configure(Some("http://events.tana.network:8508"), None, None)?;

    // Dispatch an event
    dispatch_event(Event {
        service: "edge".to_string(),
        level: EventLevel::Info,
        category: "contract_execution".to_string(),
        message: "Contract executed successfully".to_string(),
        timestamp: None, // Will be set automatically
        metadata: Some(json!({
            "contract_id": "abc123",
            "duration_ms": 45
        })),
    }).await?;

    Ok(())
}

Structs§

Config
Client configuration
Event
Core event structure
EventResponse
Response from the event bus server

Enums§

EventLevel
Event log levels

Functions§

configure
Configure the event bus client
dispatch_event
Dispatch an event to the event bus server
dispatch_event_async
Fire-and-forget event dispatch (spawns a tokio task, does not wait for response)
get_config
Get current configuration