Skip to main content

bctx_conductor/beacon/
mod.rs

1pub mod cloud;
2pub mod emitter;
3pub mod local;
4
5use chrono::{DateTime, Utc};
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct Beacon {
10    pub skill_id: String,
11    pub tokens_used: usize,
12    pub tokens_saved: usize,
13    pub duration_ms: u64,
14    pub timestamp: DateTime<Utc>,
15}
16
17impl Beacon {
18    pub fn new(
19        skill_id: impl Into<String>,
20        tokens_used: usize,
21        tokens_saved: usize,
22        duration_ms: u64,
23    ) -> Self {
24        Self {
25            skill_id: skill_id.into(),
26            tokens_used,
27            tokens_saved,
28            duration_ms,
29            timestamp: Utc::now(),
30        }
31    }
32}
33
34pub trait BeaconEmitter: Send + Sync {
35    fn emit(&self, beacon: &Beacon);
36}