CI / UI Checks (pull_request) Successful in 11s
CI / Rust Checks (pull_request) Successful in 12m45s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
Community Release / release (push) Successful in 40m35s
Tool Draft фиксирует synchronous/background/adaptive, deadline и fallback; runtime применяет единый снимок политики (concurrency, очередь, approval, deadline) до внешнего действия. Насыщение отклоняется typed overload с retry guidance, mandatory safety store fail closed, background/adaptive используют опубликованный synchronous/unsupported fallback. Refs: #29
140 lines
3.3 KiB
Rust
140 lines
3.3 KiB
Rust
pub mod access;
|
|
pub mod agents;
|
|
pub mod auth;
|
|
pub mod auth_profiles;
|
|
pub mod capabilities;
|
|
pub mod imports;
|
|
pub mod observability;
|
|
pub mod onboarding;
|
|
pub mod operations;
|
|
pub mod prompts;
|
|
pub mod resources;
|
|
pub mod secrets;
|
|
pub mod upstreams;
|
|
pub mod workspaces;
|
|
|
|
use axum::{Json, extract::State, http::StatusCode, response::IntoResponse};
|
|
use serde_json::json;
|
|
|
|
use crate::state::AppState;
|
|
|
|
pub async fn health() -> Json<serde_json::Value> {
|
|
Json(json!({
|
|
"service": "admin-api",
|
|
"status": "ok"
|
|
}))
|
|
}
|
|
|
|
pub async fn readiness(State(state): State<AppState>) -> impl IntoResponse {
|
|
let checks = state.service.readiness().await;
|
|
let postgres = if checks.postgres {
|
|
"ready"
|
|
} else {
|
|
"not_ready"
|
|
};
|
|
let artifact_storage = if checks.artifact_storage {
|
|
"ready"
|
|
} else {
|
|
"not_ready"
|
|
};
|
|
let execution_admission = if checks.execution_admission {
|
|
"ready"
|
|
} else {
|
|
"not_ready"
|
|
};
|
|
if checks.is_ready() {
|
|
(
|
|
StatusCode::OK,
|
|
Json(json!({
|
|
"service": "admin-api",
|
|
"status": "ready",
|
|
"checks": {
|
|
"postgres": postgres,
|
|
"artifact_storage": artifact_storage,
|
|
"execution_admission": execution_admission
|
|
}
|
|
})),
|
|
)
|
|
} else {
|
|
(
|
|
StatusCode::SERVICE_UNAVAILABLE,
|
|
Json(json!({
|
|
"service": "admin-api",
|
|
"status": "not_ready",
|
|
"checks": {
|
|
"postgres": postgres,
|
|
"artifact_storage": artifact_storage,
|
|
"execution_admission": execution_admission
|
|
}
|
|
})),
|
|
)
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use crate::service::ReadinessChecks;
|
|
|
|
#[test]
|
|
fn readiness_checks_identify_a_postgres_failure() {
|
|
let checks = ReadinessChecks {
|
|
postgres: false,
|
|
artifact_storage: true,
|
|
execution_admission: true,
|
|
};
|
|
assert!(!checks.is_ready());
|
|
assert_eq!(
|
|
if checks.postgres {
|
|
"ready"
|
|
} else {
|
|
"not_ready"
|
|
},
|
|
"not_ready"
|
|
);
|
|
assert_eq!(
|
|
if checks.artifact_storage {
|
|
"ready"
|
|
} else {
|
|
"not_ready"
|
|
},
|
|
"ready"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn readiness_checks_identify_an_artifact_storage_failure() {
|
|
let checks = ReadinessChecks {
|
|
postgres: true,
|
|
artifact_storage: false,
|
|
execution_admission: true,
|
|
};
|
|
assert!(!checks.is_ready());
|
|
assert_eq!(
|
|
if checks.postgres {
|
|
"ready"
|
|
} else {
|
|
"not_ready"
|
|
},
|
|
"ready"
|
|
);
|
|
assert_eq!(
|
|
if checks.artifact_storage {
|
|
"ready"
|
|
} else {
|
|
"not_ready"
|
|
},
|
|
"not_ready"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn readiness_checks_identify_an_admission_state_failure() {
|
|
let checks = ReadinessChecks {
|
|
postgres: true,
|
|
artifact_storage: true,
|
|
execution_admission: false,
|
|
};
|
|
assert!(!checks.is_ready());
|
|
}
|
|
}
|