diff --git a/Cargo.lock b/Cargo.lock index 00b94f85..18b3cb77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5027,7 +5027,6 @@ version = "0.1.0" dependencies = [ "async-nats", "axum", - "backon", "data-encoding", "hive-sh4re", "reqwest", @@ -5067,6 +5066,7 @@ dependencies = [ name = "swarm-secret-client" version = "0.1.0" dependencies = [ + "backon", "futures-util", "reqwest", "rustify", diff --git a/swarm-builder/src/main.rs b/swarm-builder/src/main.rs index 5c835f37..b0b7501f 100644 --- a/swarm-builder/src/main.rs +++ b/swarm-builder/src/main.rs @@ -74,7 +74,7 @@ async fn main() -> Result<()> { deadline: BUILD_DEADLINE, }); let secret = - swarm_queue_client::read_with_startup_retry("reading the queue client secret", || { + swarm_secret_client::read_with_startup_retry("reading the queue client secret", || { client_secret(&client_id) }) .await?; diff --git a/swarm-claude-login/src/main.rs b/swarm-claude-login/src/main.rs index 1efcf0b0..f9dce040 100644 --- a/swarm-claude-login/src/main.rs +++ b/swarm-claude-login/src/main.rs @@ -63,7 +63,7 @@ async fn main() -> Result<()> { STEP_DEADLINE, )); let secret = - swarm_queue_client::read_with_startup_retry("reading the queue client secret", || { + swarm_secret_client::read_with_startup_retry("reading the queue client secret", || { client_secret(&client_id) }) .await?; diff --git a/swarm-controller/src/queue_identity.rs b/swarm-controller/src/queue_identity.rs index 1ff98e52..7bc11062 100644 --- a/swarm-controller/src/queue_identity.rs +++ b/swarm-controller/src/queue_identity.rs @@ -58,7 +58,7 @@ pub async fn init() -> Result<()> { let identity = match coordinates_from(|name| std::env::var(name).ok())? { None => None, Some(coordinates) => { - let secret = swarm_queue_client::read_with_startup_retry( + let secret = swarm_secret_client::read_with_startup_retry( "fetching the queue client secret from the swarm secret store", fetch_secret, ) diff --git a/swarm-queue-client/Cargo.toml b/swarm-queue-client/Cargo.toml index 90d0987c..ec73a487 100644 --- a/swarm-queue-client/Cargo.toml +++ b/swarm-queue-client/Cargo.toml @@ -71,7 +71,6 @@ agents-md-initial = ["async-nats/jetstream"] # Bare (no `kv`/`jetstream`) unless a consumer opts into the `kv` feature # above - the connect itself needs none of them. async-nats.workspace = true -backon.workspace = true hive-sh4re = { workspace = true, optional = true } # `blocking` on top of the workspace default (`form`/`json`/`rustls`) — # `mint_token_for_blocking` needs `reqwest::blocking::Client` for a caller @@ -100,9 +99,6 @@ utoipa = { workspace = true, optional = true } # A loopback stand-in token endpoint for the client secret re-read tests. axum.workspace = true data-encoding.workspace = true -# `test-util` for `#[tokio::test(start_paused = true)]`: the startup-read -# retry tests run on paused time. -tokio = { workspace = true, features = ["test-util"] } [lints] workspace = true diff --git a/swarm-queue-client/src/lib.rs b/swarm-queue-client/src/lib.rs index cc74a575..018d29fe 100644 --- a/swarm-queue-client/src/lib.rs +++ b/swarm-queue-client/src/lib.rs @@ -496,9 +496,6 @@ pub mod subagent_term; /// same shapes. pub mod review_classifier; -mod startup_read; -pub use startup_read::read_with_startup_retry; - /// Only the fields this needs; authelia returns several. #[derive(serde::Deserialize)] struct TokenResponse { diff --git a/swarm-review-classifier/src/main.rs b/swarm-review-classifier/src/main.rs index 4d2e133c..653ed2e2 100644 --- a/swarm-review-classifier/src/main.rs +++ b/swarm-review-classifier/src/main.rs @@ -68,7 +68,7 @@ async fn serve() -> Result<()> { }, }; let secret = - swarm_queue_client::read_with_startup_retry("reading the queue client secret", || { + swarm_secret_client::read_with_startup_retry("reading the queue client secret", || { client_secret(&client_id) }) .await?; diff --git a/swarm-secret-client/Cargo.toml b/swarm-secret-client/Cargo.toml index 70202ed6..96a37bc3 100644 --- a/swarm-secret-client/Cargo.toml +++ b/swarm-secret-client/Cargo.toml @@ -4,6 +4,8 @@ version.workspace = true edition.workspace = true [dependencies] +# `read_with_startup_retry`'s backoff schedule. +backon.workspace = true # `Shared`, so every caller refused while a secret re-read runs waits on that # one read (`stored_secret`). futures-util.workspace = true diff --git a/swarm-secret-client/src/lib.rs b/swarm-secret-client/src/lib.rs index 45e70020..1a53f597 100644 --- a/swarm-secret-client/src/lib.rs +++ b/swarm-secret-client/src/lib.rs @@ -44,9 +44,11 @@ pub mod path; pub mod policy; pub mod queue; pub mod review_classifier; +pub mod startup_read; pub mod stored_secret; pub use client::SecretStore; +pub use startup_read::read_with_startup_retry; /// What can go wrong between "we have a client certificate" and "we have the /// credential". diff --git a/swarm-queue-client/src/startup_read.rs b/swarm-secret-client/src/startup_read.rs similarity index 100% rename from swarm-queue-client/src/startup_read.rs rename to swarm-secret-client/src/startup_read.rs