use metric::{LogLine, Telemetry};
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub enum Encoding {
Raw,
Avro,
JSON,
}
#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
pub enum Event {
Telemetry(Telemetry),
Log(LogLine),
TimerFlush(u64),
Shutdown,
Raw {
order_by: u64,
encoding: Encoding,
bytes: Vec<u8>,
},
}
impl Event {
pub fn is_timer_flush(&self) -> bool {
match *self {
Event::TimerFlush(_) => true,
_ => false,
}
}
pub fn timestamp(&self) -> Option<i64> {
match *self {
Event::Telemetry(ref telem) => Some(telem.timestamp),
Event::Log(ref log) => Some(log.time),
Event::TimerFlush(_) | Event::Shutdown | Event::Raw { .. } => None,
}
}
}
impl Event {
#[inline]
pub fn new_telemetry(metric: Telemetry) -> Event {
Event::Telemetry(metric)
}
#[inline]
pub fn new_log(log: LogLine) -> Event {
Event::Log(log)
}
}