-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathprune.rs
38 lines (34 loc) · 1000 Bytes
/
prune.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::interfaces::HostResult;
use axum::{extract::State, routing::post, Router};
use raiko_reqactor::Actor;
use utoipa::OpenApi;
#[utoipa::path(post, path = "/proof/prune",
tag = "Proving",
responses (
(status = 200, description = "Successfully pruned tasks", body = PruneStatus)
)
)]
/// Prune all tasks.
async fn prune_handler(State(actor): State<Actor>) -> HostResult<()> {
let statuses = actor
.pool_list_status()
.await
.map_err(|e| anyhow::anyhow!(e))?;
for (key, status) in statuses {
tracing::info!("Pruning task: {key} with status: {status}");
let _ = actor
.pool_remove_request(&key)
.await
.map_err(|e| anyhow::anyhow!(e))?;
}
Ok(())
}
#[derive(OpenApi)]
#[openapi(paths(prune_handler))]
struct Docs;
pub fn create_docs() -> utoipa::openapi::OpenApi {
Docs::openapi()
}
pub fn create_router() -> Router<Actor> {
Router::new().route("/", post(prune_handler))
}