feat: with agent db

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-27 19:42:33 +02:00
parent 75d99c2461
commit 43ed89d0d8
10 changed files with 286 additions and 68 deletions

View File

@@ -1,13 +1,13 @@
use std::collections::HashMap;
use std::sync::Arc;
use axum::async_trait;
use churn_domain::{LogEvent, ServerEnrollReq};
use churn_domain::{LogEvent};
use itertools::Itertools;
use serde::{ser::SerializeStruct, Deserialize, Serialize};
use tokio::sync::{Mutex, RwLock};
use churn_capnp::CapnpPackExt;
@@ -68,14 +68,13 @@ impl EventServiceTrait for DefaultEventService {
let events = events
.iter()
.map(|e| match LogEvent::deserialize_capnp(e) {
.flat_map(|e| match LogEvent::deserialize_capnp(e) {
Ok(o) => Ok(o),
Err(e) => {
tracing::error!("failed to deserialize capnp: {e}");
Err(e)
}
})
.flatten()
.sorted_by_key(|i| i.timestamp)
.skip_while(|item| item.id != cursor)
.skip(1)
@@ -88,8 +87,7 @@ impl EventServiceTrait for DefaultEventService {
let events = events
.iter()
.map(|e| LogEvent::deserialize_capnp(e))
.flatten()
.flat_map(LogEvent::deserialize_capnp)
.sorted_by_key(|i| i.timestamp)
.collect();