Skip to main content

loa_core/
lib.rs

1//! Embeddable Lightweight Observability (elo)
2//!
3//! A library for building observability agents with proper supervision and actor-based architecture.
4//!
5//! # Example
6//!
7//! ```no_run
8//! use elo::Agent;
9//!
10//! #[tokio::main]
11//! async fn main() -> anyhow::Result<()> {
12//!     let agent = Agent::builder()
13//!         .storage_path("/var/lib/loa")
14//!         .build()
15//!         .await?;
16//!
17//!     agent.run().await?;
18//!     Ok(())
19//! }
20//! ```
21
22mod agent;
23mod builder;
24mod identity;
25mod supervisor;
26
27pub mod constants;
28pub mod core;
29pub mod http;
30
31/// Compile-time version from Cargo.toml
32pub const VERSION: &str = env!("CARGO_PKG_VERSION");
33
34pub use agent::Agent;
35pub use builder::AgentBuilder;
36pub use identity::{AgentIdentity, AgentInfo, get_global_identity, init_global_identity};
37
38/// Result type alias for elo operations
39pub type Result<T> = std::result::Result<T, Error>;
40
41/// Error types for elo
42#[derive(Debug, thiserror::Error)]
43pub enum Error {
44    #[error("IO error: {0}")]
45    Io(#[from] std::io::Error),
46
47    #[error("Actor error: {0}")]
48    Actor(String),
49
50    #[error("Configuration error: {0}")]
51    Config(String),
52
53    #[error("Supervisor error: {0}")]
54    Supervisor(String),
55}
56
57// Convert ractor errors to our Error type
58impl From<ractor::SpawnErr> for Error {
59    fn from(e: ractor::SpawnErr) -> Self {
60        Error::Actor(e.to_string())
61    }
62}