This commit is contained in:
2023-09-23 00:57:35 +02:00
parent 5fb4f6b7a7
commit 3fdad853f0
6 changed files with 149 additions and 283 deletions

View File

@@ -1,6 +1,6 @@
use std::time::Duration;
use axum::{Router, routing::{get, post}, middleware::{self, Next}, http::{Request, StatusCode, self}, response::{Response, IntoResponse}, extract::{Path}, Json};
use axum::{Router, routing::{get, post}, middleware::{self, Next}, http::{Request, StatusCode, self}, response::{Response, IntoResponse}, extract::Path, Json};
use axum_prometheus::PrometheusMetricLayer;
use moka::future::Cache;
use once_cell::sync::Lazy;
@@ -24,7 +24,7 @@ async fn create_archive_task(
) -> impl IntoResponse {
let key = get_key(data.clone());
let result = match TASK_RESULTS.get(&key) {
let result = match TASK_RESULTS.get(&key).await {
Some(result) => {
if result.status == TaskStatus::Failed {
create_task(data).await
@@ -42,7 +42,7 @@ async fn create_archive_task(
async fn check_archive_task_status(
Path(task_id): Path<String>
) -> impl IntoResponse {
match TASK_RESULTS.get(&task_id) {
match TASK_RESULTS.get(&task_id).await {
Some(result) => Json::<Task>(result).into_response(),
None => StatusCode::NOT_FOUND.into_response(),
}