Skip to content

Commit be0f79f

Browse files
committed
wip influx handler
1 parent c860860 commit be0f79f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

software/tracksight/rust_backend/src/tasks/influx_handler.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use influxdb2::models::DataPoint;
12
use tokio::sync::broadcast::Receiver;
23
use influxdb2::Client;
34
use tokio::select;
@@ -27,7 +28,14 @@ pub async fn run_influx_handler(mut shutdown_signal: Receiver<()>, mut can_queue
2728
Ok(can) = can_queue_receiver.recv() => {
2829
// todo should also probably check for closed channels and close thread
2930
let CanMessage { can_id, can_time_offset, can_payload } = can;
30-
// todo handle
31+
let influx_data = vec![
32+
DataPoint::builder(&CONFIG.influxdb_measurement)
33+
.tag("can_id", can_id.to_string())
34+
.field("can_time_offset", can_time_offset as i64)
35+
.field("can_payload", can_payload.iter().map(|b| *b as i64).collect::<Vec<i64>>())
36+
.build().unwrap()
37+
];
38+
influx_client.write(&CONFIG.influxdb_bucket,);
3139
}
3240
}
3341
}

0 commit comments

Comments
 (0)