Skip to main content

objectiveai_cli/command/db/
kill.rs

1//! `db kill --global|--state` — terminate db server(s) by
2//! killing the owner(s) of their per-state lock at
3//! `<dir>/state/<state>/locks` key `db`. `--state` hits the
4//! current state; `--global` fans out across every state
5//! concurrently. Idempotent: a count of zero is not an error.
6
7use objectiveai_sdk::cli::command::db::kill::{Request, Response};
8
9use crate::command::kill_helpers::kill_per_state;
10use crate::context::Context;
11use crate::error::Error;
12
13pub async fn execute(ctx: &Context, request: Request) -> Result<Response, Error> {
14    let killed = kill_per_state(ctx, request.scope, "db").await?;
15    Ok(Response { killed })
16}
17
18pub mod request_schema {
19    use objectiveai_sdk::cli::command::db::kill as sdk;
20    use objectiveai_sdk::cli::command::db::kill::request_schema::{Request, Response};
21
22    use crate::context::Context;
23    use crate::error::Error;
24
25    pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
26        Ok(objectiveai_sdk::cli::command::ResponseSchema(schemars::schema_for!(sdk::Request)))
27    }
28}
29
30pub mod response_schema {
31    use objectiveai_sdk::cli::command::db::kill as sdk;
32    use objectiveai_sdk::cli::command::db::kill::response_schema::{Request, Response};
33
34    use crate::context::Context;
35    use crate::error::Error;
36
37    pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
38        Ok(objectiveai_sdk::cli::command::ResponseSchema(schemars::schema_for!(sdk::Response)))
39    }
40}