Started to implement proper event processing.

This commit is contained in:
didier amyot committed 2023-02-23 13:41:47 -05:00
1 parent af11915a52
commit 238cd9f2da
7 files changed
+75 -88

No files matched your search

+13 -5
View File
@@ -1,13 +1,21 @@
use std::io;
pub async fn worker_loop(r: async_channel::Receiver<i32>) -> io::Result<()> {
use rusqlite::Connection;
use crate::event_processor::process_event;
use crate::events::Event;
use crate::util::CustomResult;
use crate::util::Error::FuckingError;
pub async fn worker_loop(conn: &mut Connection,
r: async_channel::Receiver<Event>) -> CustomResult<()> {
loop {
let x = r.recv().await;
match x {
Ok(v) => println!("Processed value: {:?}", v),
let res = r.recv().await;
match res {
Ok(event) => process_event(conn, event)?, // todo, remove ?
Err(e) => {
println!("Error: {:?}", e);
return Ok(());
return Err(FuckingError(e.to_string()));
}
}
}