@@ -15,11 +15,11 @@ use axum::http::StatusCode;
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use axum::routing::{get, post};
|
||||
use axum::{Json, Router};
|
||||
use churn_domain::{LeaseResp, LogEvent, ServerEnrollReq, ServerMonitorResp};
|
||||
use churn_domain::{Agent, LeaseResp, LogEvent, ServerEnrollReq, ServerMonitorResp};
|
||||
use clap::{Args, Parser, Subcommand, ValueEnum};
|
||||
use event::EventService;
|
||||
use lease::LeaseService;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::db::Db;
|
||||
@@ -56,11 +56,6 @@ enum Commands {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
struct Agent {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct AppState {
|
||||
agent: AgentService,
|
||||
@@ -94,9 +89,9 @@ async fn main() -> anyhow::Result<()> {
|
||||
.route("/lease", post(agent_lease)),
|
||||
)
|
||||
.with_state(AppState {
|
||||
agent: AgentService::default(),
|
||||
agent: AgentService::new(db.clone()),
|
||||
leases: LeaseService::default(),
|
||||
events: EventService::new(db),
|
||||
events: EventService::new(db.clone()),
|
||||
});
|
||||
|
||||
tracing::info!("churn server listening on {}", host);
|
||||
@@ -221,7 +216,7 @@ async fn logs(
|
||||
|
||||
if events.is_empty() {
|
||||
return Ok(Json(ServerMonitorResp {
|
||||
cursor: cursor.cursor.clone(),
|
||||
cursor: cursor.cursor,
|
||||
logs: Vec::new(),
|
||||
}));
|
||||
}
|
||||
|
Reference in New Issue
Block a user