swarm-controller: split main.rs into jobq, routes and startup modules
no behaviour change: a pure move of items and tests into new modules, plus visibility edits (pub(crate)) and path updates in sibling modules that named crate-root items. same routes, same OpenAPI, 561 tests before and after. why: #5470, new features stop landing in one 6.4k-line file by default. files outside swarm-controller/src: docs/agent-lifecycle/agent-roster.md, swarm-ui JobsPage.tsx and AgentsPage.tsx, nix/host-modules/swarm-controller.nix and swarm-grafana.nix hold comments that named main.rs for items that moved.
This commit is contained in:
parent
f0a6d6c042
commit
738dd1c95b
42 changed files with 6854 additions and 6680 deletions
|
|
@ -38,7 +38,7 @@ use utoipa::{IntoParams, ToSchema};
|
|||
|
||||
use self::settings::{Settings, SettingsSource};
|
||||
use crate::forge::{self, DefaultBranchFiles, PullForReview};
|
||||
use crate::{AppState, error_problem};
|
||||
use crate::routes::{AppState, error_problem};
|
||||
|
||||
pub(crate) mod open_pr;
|
||||
pub(crate) mod review;
|
||||
|
|
@ -715,7 +715,7 @@ async fn start(
|
|||
fn settings_problem(e: &anyhow::Error) -> ProblemDetails {
|
||||
let detail = format!("{e:#}");
|
||||
tracing::warn!(error = %detail, "reading the review classifier's settings for a try-out failed");
|
||||
error_problem(crate::wanted_error_status(e), &detail)
|
||||
error_problem(crate::routes::wanted_error_status(e), &detail)
|
||||
}
|
||||
|
||||
/// 404 when the forge knows no such repo or PR, 503 for anything else.
|
||||
|
|
@ -915,9 +915,9 @@ pub(crate) mod tests {
|
|||
}
|
||||
|
||||
fn app_with_files(reply: Reply, files: Vec<(&'static str, String)>) -> axum::Router {
|
||||
let (mut state, _) = crate::tests::state_with_roster();
|
||||
let (mut state, _) = crate::routes::tests::state_with_roster();
|
||||
state.try_outs.fake = Some(Arc::new(Fake::new(reply, files)));
|
||||
crate::build_app(state)
|
||||
crate::startup::build_app(state)
|
||||
}
|
||||
|
||||
fn body(repo: &str, pr: u64) -> String {
|
||||
|
|
@ -1001,7 +1001,7 @@ pub(crate) mod tests {
|
|||
cache_write: None,
|
||||
},
|
||||
};
|
||||
let (mut state, _) = crate::tests::state_with_roster();
|
||||
let (mut state, _) = crate::routes::tests::state_with_roster();
|
||||
let fake = Arc::new(Fake {
|
||||
settings: Settings {
|
||||
model: "opus".to_owned(),
|
||||
|
|
@ -1013,7 +1013,7 @@ pub(crate) mod tests {
|
|||
..Fake::new(done(), Vec::new())
|
||||
});
|
||||
state.try_outs.fake = Some(Arc::clone(&fake));
|
||||
let app = crate::build_app(state);
|
||||
let app = crate::startup::build_app(state);
|
||||
let (status, accepted) = post(&app, body("o/r", 7)).await;
|
||||
assert_eq!(status, StatusCode::ACCEPTED, "{accepted}");
|
||||
settled(&app, accepted["id"].as_str().expect("an id")).await;
|
||||
|
|
@ -1051,10 +1051,10 @@ pub(crate) mod tests {
|
|||
(failed, runs::RunOutcome::Failed, Some("no API key")),
|
||||
] {
|
||||
let doc = Arc::new(runs::tests::FakeDoc::default());
|
||||
let (mut state, _) = crate::tests::state_with_roster();
|
||||
let (mut state, _) = crate::routes::tests::state_with_roster();
|
||||
state.try_outs.fake = Some(Arc::new(Fake::new(reply.clone(), Vec::new())));
|
||||
state.runs = runs::Runs::Fake(Arc::clone(&doc));
|
||||
let app = crate::build_app(state);
|
||||
let app = crate::startup::build_app(state);
|
||||
let (_, accepted) = post(&app, body("o/r", 7)).await;
|
||||
let id = accepted["id"].as_str().expect("an id");
|
||||
settled(&app, id).await;
|
||||
|
|
@ -1481,8 +1481,8 @@ classifications:
|
|||
|
||||
#[tokio::test]
|
||||
async fn rules_without_forge_access_on_this_host_are_503() {
|
||||
let (state, _) = crate::tests::state_with_roster();
|
||||
let (status, problem) = get_rules(&crate::build_app(state), "?repo=o/r").await;
|
||||
let (state, _) = crate::routes::tests::state_with_roster();
|
||||
let (status, problem) = get_rules(&crate::startup::build_app(state), "?repo=o/r").await;
|
||||
assert_eq!(status, StatusCode::SERVICE_UNAVAILABLE, "{problem}");
|
||||
assert_eq!(problem["detail"], "no forge access on this host yet");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue