Module agent

Module agent 

Source
Expand description

PhyTrace Agent - The main SDK entry point.

The agent orchestrates event building, emission, buffering, and transmission.

§Example

use phytrace_sdk::{PhyTraceAgent, PhyTraceConfig, SourceType};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = PhyTraceConfig::new("robot-001")
        .with_endpoint("https://api.phyware.io")
        .with_api_key("your-api-key")
        .with_source_type(SourceType::Amr);

    let agent = PhyTraceAgent::from_config(config).await?;
     
    // Start the agent
    agent.start().await?;

    // Emit events
    agent.emit()
        .position_2d(10.0, 20.0)
        .battery_soc(85.0)
        .send()
        .await?;

    // Shutdown gracefully
    agent.shutdown().await?;
     
    Ok(())
}

Structs§

AgentEventBuilder
Fluent event builder that integrates with the agent.
PhyTraceAgent
The main PhyTrace SDK agent.