2 unstable releases
| 0.2.1 | Dec 7, 2025 |
|---|---|
| 0.1.0 | Nov 25, 2025 |
#1242 in Debugging
16KB
176 lines
tana-event-bus
Rust client library for dispatching events to the Tana Event Bus server.
Installation
Add to your Cargo.toml:
[dependencies]
tana-event-bus = "0.1"
Usage
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 startup
configure(
Some("http://events.tana.network:8508"),
Some(10), // timeout seconds
Some(5) // max retries
)?;
// Dispatch an event
let response = 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?;
println!("Event ID: {:?}", response.message_id);
Ok(())
}
Fire-and-Forget
For high-frequency events where you don't need confirmation:
use tana_event_bus::{dispatch_event_async, Event, EventLevel};
fn handle_request() {
// Non-blocking dispatch
dispatch_event_async(Event {
service: "edge".to_string(),
level: EventLevel::Debug,
category: "performance".to_string(),
message: "Request processed".to_string(),
timestamp: None,
metadata: None,
});
}
Configuration
The client can be configured via:
- Environment variable:
EVENT_BUS_URL(default:http://localhost:8508) - Code:
configure()function
License
MIT
Dependencies
~6–23MB
~258K SLoC