pub struct PhyTraceAgent { /* private fields */ }Expand description
The main PhyTrace SDK agent.
Manages the complete event lifecycle:
- License validation
- Event building and validation
- Provenance signing (optional)
- Batching and buffering
- Transport with retry logic
Implementations§
Source§impl PhyTraceAgent
impl PhyTraceAgent
Sourcepub async fn from_config(config: PhyTraceConfig) -> PhyTraceResult<Self>
pub async fn from_config(config: PhyTraceConfig) -> PhyTraceResult<Self>
Create an agent from configuration.
Sourcepub async fn from_config_with_signer(
config: PhyTraceConfig,
signer: Option<Arc<dyn Signer>>,
) -> PhyTraceResult<Self>
pub async fn from_config_with_signer( config: PhyTraceConfig, signer: Option<Arc<dyn Signer>>, ) -> PhyTraceResult<Self>
Create an agent from configuration that signs with signer, e.g. a
phytrace_tpm::TpmSigner, instead of the HMAC key in
config.provenance. config.provenance.sequence_path still applies.
Sourcepub async fn with_transport(
config: PhyTraceConfig,
transport: Box<dyn Transport>,
) -> PhyTraceResult<Self>
pub async fn with_transport( config: PhyTraceConfig, transport: Box<dyn Transport>, ) -> PhyTraceResult<Self>
Create an agent with a custom transport.
Sourcepub async fn with_transport_and_signer(
config: PhyTraceConfig,
transport: Box<dyn Transport>,
signer: Option<Arc<dyn Signer>>,
) -> PhyTraceResult<Self>
pub async fn with_transport_and_signer( config: PhyTraceConfig, transport: Box<dyn Transport>, signer: Option<Arc<dyn Signer>>, ) -> PhyTraceResult<Self>
Create an agent with a custom transport and, optionally, a signing
back end that replaces the HMAC key in config.provenance.
Sourcepub async fn from_file<P: AsRef<Path>>(path: P) -> PhyTraceResult<Self>
pub async fn from_file<P: AsRef<Path>>(path: P) -> PhyTraceResult<Self>
Load configuration from a YAML file and create agent.
Sourcepub async fn start(&self) -> PhyTraceResult<()>
pub async fn start(&self) -> PhyTraceResult<()>
Start the agent.
Sourcepub async fn shutdown(&self) -> PhyTraceResult<()>
pub async fn shutdown(&self) -> PhyTraceResult<()>
Stop the agent gracefully.
Sourcepub fn emit(&self) -> AgentEventBuilder<'_>
pub fn emit(&self) -> AgentEventBuilder<'_>
Create an event builder for fluent emission.
Sourcepub async fn send(&self, event: UdmEvent) -> PhyTraceResult<()>
pub async fn send(&self, event: UdmEvent) -> PhyTraceResult<()>
Send a pre-built event.
Sourcepub async fn flush(&self) -> PhyTraceResult<()>
pub async fn flush(&self) -> PhyTraceResult<()>
Flush buffered events immediately.
Sourcepub async fn stats(&self) -> TransportStats
pub async fn stats(&self) -> TransportStats
Get transport statistics.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the agent is running.
Sourcepub fn config(&self) -> &PhyTraceConfig
pub fn config(&self) -> &PhyTraceConfig
Get a reference to the configuration.
Sourcepub fn set_validation_level(&mut self, level: ValidationLevel)
pub fn set_validation_level(&mut self, level: ValidationLevel)
Set the validation level.