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
|
|
@ -19,8 +19,8 @@ use serde::{Deserialize, Serialize};
|
|||
use swarm_queue_client::agent_limits::{self, AgentCaps};
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use crate::routes::{AppState, error_problem, wanted_error_status};
|
||||
use crate::schedules::{live, queue, read_or_default, refused, write_revision};
|
||||
use crate::{AppState, error_problem, wanted_error_status};
|
||||
|
||||
/// How many times a losing writer re-reads and re-applies, as in
|
||||
/// `wanted::MAX_ATTEMPTS`.
|
||||
|
|
@ -478,9 +478,9 @@ pub(crate) mod tests {
|
|||
}
|
||||
|
||||
/// One hive, `pr1ma`, on `client`.
|
||||
pub(crate) fn state(client: &async_nats::Client) -> crate::AppState {
|
||||
crate::AppState {
|
||||
hives: Arc::new(vec![crate::HiveEntry {
|
||||
pub(crate) fn state(client: &async_nats::Client) -> crate::routes::AppState {
|
||||
crate::routes::AppState {
|
||||
hives: Arc::new(vec![crate::routes::hives::HiveEntry {
|
||||
name: "pr1ma".to_owned(),
|
||||
domain: "pr1ma.example".to_owned(),
|
||||
dashboard: "pr1ma.hives.example".to_owned(),
|
||||
|
|
@ -516,7 +516,7 @@ pub(crate) mod tests {
|
|||
}
|
||||
|
||||
/// A state on a real server whose `pr1ma` declares `atlas`.
|
||||
pub(crate) async fn declared(client: &async_nats::Client) -> crate::AppState {
|
||||
pub(crate) async fn declared(client: &async_nats::Client) -> crate::routes::AppState {
|
||||
WantedWriter::new(client.clone())
|
||||
.set("pr1ma", "atlas", AgentState::Up)
|
||||
.await
|
||||
|
|
@ -532,7 +532,7 @@ pub(crate) mod tests {
|
|||
}
|
||||
|
||||
async fn put(
|
||||
state: &crate::AppState,
|
||||
state: &crate::routes::AppState,
|
||||
agent: &str,
|
||||
value: Caps,
|
||||
) -> Result<axum::Json<Caps>, problem_details::ProblemDetails> {
|
||||
|
|
@ -544,7 +544,7 @@ pub(crate) mod tests {
|
|||
.await
|
||||
}
|
||||
|
||||
async fn get(state: &crate::AppState, agent: &str) -> Caps {
|
||||
async fn get(state: &crate::routes::AppState, agent: &str) -> Caps {
|
||||
get_agent_limits(State(state.clone()), Path(agent.to_owned()))
|
||||
.await
|
||||
.expect("caps are read")
|
||||
|
|
@ -662,7 +662,7 @@ pub(crate) mod tests {
|
|||
let _ = put(&state, "atlas", caps(Some("400%"), Some("8G")))
|
||||
.await
|
||||
.expect("cap atlas");
|
||||
crate::build_app(state)
|
||||
crate::startup::build_app(state)
|
||||
}
|
||||
|
||||
async fn put_raw(app: &axum::Router, body: &'static str) -> StatusCode {
|
||||
|
|
|
|||
Loading…
Reference in a new issue