Restructure server around Server struct

This commit is contained in:
Joscha 2023-08-07 14:43:36 +02:00
parent 45abda2b6d
commit 9bdfc79c8b
5 changed files with 92 additions and 95 deletions

View file

@ -8,9 +8,9 @@ mod repo;
use tracing::{debug_span, error, Instrument};
use crate::state::AppState;
use super::Server;
async fn recurring_task(state: &AppState) {
async fn recurring_task(state: &Server) {
async {
if let Err(e) = repo::update(&state.db, state.repo.clone()).await {
error!("Error updating repo:\n{e:?}");
@ -28,7 +28,7 @@ async fn recurring_task(state: &AppState) {
.await;
}
pub async fn run(state: AppState) {
pub async fn run(state: Server) {
loop {
recurring_task(&state).await;
tokio::time::sleep(state.config.repo.update_delay).await;