| Crates.io | tana-event-bus |
| lib.rs | tana-event-bus |
| version | 0.2.1 |
| created_at | 2025-11-25 01:25:49.087253+00 |
| updated_at | 2025-12-07 00:01:43.045627+00 |
| description | Rust client library for Tana Event Bus |
| homepage | |
| repository | https://github.com/tananetwork/tana-event-bus |
| max_upload_size | |
| id | 1949010 |
| size | 56,778 |
Rust client library for dispatching events to the Tana Event Bus server.
Add to your Cargo.toml:
[dependencies]
tana-event-bus = "0.1"
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(())
}
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,
});
}
The client can be configured via:
EVENT_BUS_URL (default: http://localhost:8508)configure() functionMIT