From ab09a8ee1d9278bb71ddeff249388130d3464e16 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Tue, 29 Sep 2026 15:20:05 +0900 Subject: [PATCH] bobbin: rename `mirror_v2` to `mirror` Signed-off-by: Seongmin Lee --- bobbin/crates/bobbin/src/config.rs | 13 +--- bobbin/crates/bobbin/src/main.rs | 16 ++--- bobbin/crates/xrpc/src/feed.rs | 2 +- bobbin/crates/xrpc/src/lib.rs | 69 ++++++++----------- bobbin/crates/xrpc/src/profile_activity.rs | 2 +- bobbin/crates/xrpc/tests/aggregation.rs | 2 +- .../{mirror_v2_proxy.rs => mirror_proxy.rs} | 2 +- bobbin/example.toml | 8 +-- bobbin/worker/src/index.ts | 2 - bobbin/worker/wrangler.dev.jsonc | 1 - docker-compose.yml | 2 +- 11 files changed, 40 insertions(+), 79 deletions(-) rename bobbin/crates/xrpc/tests/{mirror_v2_proxy.rs => mirror_proxy.rs} (99%) diff --git a/bobbin/crates/bobbin/src/config.rs b/bobbin/crates/bobbin/src/config.rs index 416347a5c..a7dd47b0b 100644 --- a/bobbin/crates/bobbin/src/config.rs +++ b/bobbin/crates/bobbin/src/config.rs @@ -38,7 +38,6 @@ const KNOWN_KEYS: &[&str] = &[ "knot.allow_private", "knot.require_https", "mirror.url", - "mirror_v2.url", "pocket.url", "log.format", "log.filter", @@ -74,7 +73,6 @@ const KNOWN_ENVS: &[&str] = &[ "BOBBIN_KNOT_ALLOW_PRIVATE", "BOBBIN_KNOT_REQUIRE_HTTPS", "BOBBIN_MIRROR_URL", - "BOBBIN_MIRROR_V2_URL", "BOBBIN_POCKET_URL", "BOBBIN_LOG_FORMAT", "BOBBIN_LOG", @@ -121,9 +119,6 @@ pub struct BobbinConfig { #[config(nested)] pub mirror: MirrorConfig, - #[config(nested)] - pub mirror_v2: MirrorV2Config, - #[config(nested)] pub pocket: PocketConfig, @@ -331,17 +326,11 @@ pub struct KnotConfig { #[derive(Debug, Config)] pub struct MirrorConfig { + /// Origin of the mirror (gitmirror) XRPC server. #[config(env = "BOBBIN_MIRROR_URL")] pub url: Option, } -#[derive(Debug, Config)] -pub struct MirrorV2Config { - /// Origin of a v2 mirror (gitmirror) XRPC server. - #[config(env = "BOBBIN_MIRROR_V2_URL")] - pub url: Option, -} - #[derive(Debug, Config)] pub struct PocketConfig { /// Origin of a pocket instance holding per-account preferences. diff --git a/bobbin/crates/bobbin/src/main.rs b/bobbin/crates/bobbin/src/main.rs index 41277a80e..71e53a16d 100644 --- a/bobbin/crates/bobbin/src/main.rs +++ b/bobbin/crates/bobbin/src/main.rs @@ -267,20 +267,13 @@ async fn run(cfg: BobbinConfig) -> anyhow::Result<()> { .map(|url| MirrorProxy::new(url, clock.clone(), hasher.clone()).map(Arc::new)) .transpose() .context("mirror.url")?; - let mirror_v2 = cfg - .mirror_v2 - .url - .as_ref() - .map(|url| MirrorProxy::new(url, clock.clone(), hasher.clone()).map(Arc::new)) - .transpose() - .context("mirror_v2.url")?; - match mirror_v2.as_ref() { + match mirror.as_ref() { Some(m) => tracing::info!( - mirror_v2 = %m.host().url(), - "we will forward few sh.tangled.git.* to the v2 knotmirror", + mirror = %m.host().url(), + "we will forward few sh.tangled.git.* to the mirror", ), None => { - tracing::info!("some sh.tangled.git.* methods will fail, since mirror_v2.url is unset",) + tracing::info!("some sh.tangled.git.* methods will fail, since mirror.url is unset",) } } let codesearch = cfg @@ -485,7 +478,6 @@ async fn run(cfg: BobbinConfig) -> anyhow::Result<()> { .with_actors(actors) .with_limiter(limiter) .with_mirror(mirror) - .with_mirror_v2(mirror_v2) .with_proxies(trusted_proxies) .with_cors(cfg.server.cors_origins.clone()) .with_service_did(cfg.service_auth.did.clone()) diff --git a/bobbin/crates/xrpc/src/feed.rs b/bobbin/crates/xrpc/src/feed.rs index 76e998dda..7ab7d87d1 100644 --- a/bobbin/crates/xrpc/src/feed.rs +++ b/bobbin/crates/xrpc/src/feed.rs @@ -102,7 +102,7 @@ async fn comment_view( let change = state .change_ids .get( - state.mirror_v2.as_deref(), + state.mirror.as_deref(), &commit.repo, commit.commit.oid.as_ref(), ) diff --git a/bobbin/crates/xrpc/src/lib.rs b/bobbin/crates/xrpc/src/lib.rs index cccceba3a..9cff48095 100644 --- a/bobbin/crates/xrpc/src/lib.rs +++ b/bobbin/crates/xrpc/src/lib.rs @@ -217,7 +217,6 @@ pub struct AppState { pub pull_statuses: Arc>, pub coverage: Arc, pub mirror: Option>, - pub mirror_v2: Option>, pub search: Arc, /// Zoekt-backed code search. `None` when unconfigured, and the endpoint answers 501. pub codesearch: Option>, @@ -269,7 +268,6 @@ impl AppState { pull_statuses, coverage, mirror: None, - mirror_v2: None, search, codesearch: None, pocket: None, @@ -314,11 +312,6 @@ impl AppState { self } - pub fn with_mirror_v2(mut self, mirror_v2: Option>) -> Self { - self.mirror_v2 = mirror_v2; - self - } - pub fn with_codesearch(mut self, codesearch: Option>) -> Self { self.codesearch = codesearch; self @@ -690,7 +683,7 @@ pub fn router(state: AppState) -> Router { &format!("/xrpc/{}", pocket::PUT_PREFERENCES), axum::routing::post(pocket::put_preferences), ) - .merge(mirror_v2_routes()) + .merge(mirror_routes()) .layer( TraceLayer::new_for_http() .make_span_with(DefaultMakeSpan::new().level(Level::INFO)) @@ -730,7 +723,7 @@ impl OnFailure for LatencyFreeTrace { } } -const MIRROR_V2_PROXIED_NSIDS: &[&str] = &[ +const MIRROR_PROXIED_NSIDS: &[&str] = &[ "sh.tangled.git.temp2.getBlame", "sh.tangled.git.temp2.getBlob", "sh.tangled.git.temp2.getDiff", @@ -752,7 +745,7 @@ const MIRROR_V2_PROXIED_NSIDS: &[&str] = &[ "sh.tangled.git.temp.listLanguages", ]; -const MIRROR_V2_WRITE_NSIDS: &[&str] = &[ +const MIRROR_WRITE_NSIDS: &[&str] = &[ "sh.tangled.git.mergeCommit", "org.tangled.temp.git.mergeCommit", "org.tangled.temp.git.deleteBranch", @@ -777,29 +770,23 @@ const RANGE_OR_CONDITIONAL_HEADERS: &[&HeaderName] = type ProxyParams = Vec<(String, String)>; -fn mirror_v2_routes() -> Router { - let reads = register_proxied( - Router::new(), - MIRROR_V2_PROXIED_NSIDS, - proxy_mirror_v2_handler, - ); - register_mirror_v2_writes(reads) +fn mirror_routes() -> Router { + let reads = register_proxied(Router::new(), MIRROR_PROXIED_NSIDS, proxy_mirror_handler); + register_mirror_writes(reads) } -fn register_mirror_v2_writes(router: Router) -> Router { - MIRROR_V2_WRITE_NSIDS - .iter() - .fold(router, |router, &nsid_lit| { - let nsid = nsid_static(nsid_lit); - router.route( - &format!("/xrpc/{nsid_lit}"), - axum::routing::post( - move |State(state): State, headers: HeaderMap, body: Bytes| { - proxy_mirror_v2_write_handler(state, headers, body, nsid.clone()) - }, - ), - ) - }) +fn register_mirror_writes(router: Router) -> Router { + MIRROR_WRITE_NSIDS.iter().fold(router, |router, &nsid_lit| { + let nsid = nsid_static(nsid_lit); + router.route( + &format!("/xrpc/{nsid_lit}"), + axum::routing::post( + move |State(state): State, headers: HeaderMap, body: Bytes| { + proxy_mirror_write_handler(state, headers, body, nsid.clone()) + }, + ), + ) + }) } fn register_proxied( @@ -4140,44 +4127,44 @@ fn upstream_to_axum(resp: ProxyResponse) -> Response { response } -async fn proxy_mirror_v2_handler( +async fn proxy_mirror_handler( state: AppState, headers: HeaderMap, socket: SocketPeer, params: ProxyParams, nsid: Nsid, ) -> Result { - let mirror_v2 = state - .mirror_v2 + let mirror = state + .mirror .as_ref() - .ok_or_else(|| XrpcError::UpstreamUnavailable("mirror_v2.url is unset".into()))?; + .ok_or_else(|| XrpcError::UpstreamUnavailable("mirror.url is unset".into()))?; let allowed = filter_request_headers(&headers, socket, &state.client_address); let forward: Vec<(&str, &str)> = params .iter() .map(|(k, v)| (k.as_str(), v.as_str())) .collect(); - mirror_v2 + mirror .forward_raw(&nsid, &forward, allowed) .await .map(upstream_to_axum) .map_err(map_proxy_error) } -async fn proxy_mirror_v2_write_handler( +async fn proxy_mirror_write_handler( state: AppState, headers: HeaderMap, body: Bytes, nsid: Nsid, ) -> Result { - let mirror_v2 = state - .mirror_v2 + let mirror = state + .mirror .as_ref() - .ok_or_else(|| XrpcError::UpstreamUnavailable("mirror_v2.url is unset".into()))?; + .ok_or_else(|| XrpcError::UpstreamUnavailable("mirror.url is unset".into()))?; let token = headers .get(AUTHORIZATION) .ok_or_else(|| XrpcError::AuthRequired("the mirror needs a service-auth token".into()))?; - let url = format!("{}xrpc/{nsid}", mirror_v2.host().url().as_str(),); + let url = format!("{}xrpc/{nsid}", mirror.host().url().as_str(),); let request = reqwest::Client::new() .post(url) .header(AUTHORIZATION, token) diff --git a/bobbin/crates/xrpc/src/profile_activity.rs b/bobbin/crates/xrpc/src/profile_activity.rs index 9f0d27ea1..68c604fbb 100644 --- a/bobbin/crates/xrpc/src/profile_activity.rs +++ b/bobbin/crates/xrpc/src/profile_activity.rs @@ -79,7 +79,7 @@ pub(crate) async fn get_profile_activity( let now = Utc::now(); let commit_counts = state .commit_stats_cache - .get(state.mirror_v2.clone(), &query.actor); + .get(state.mirror.clone(), &query.actor); let (skeleton, truncated) = collect_skeleton(&state.edges, &query.actor, now, months); let hydration = stream::iter( skeleton diff --git a/bobbin/crates/xrpc/tests/aggregation.rs b/bobbin/crates/xrpc/tests/aggregation.rs index d465d684f..de6a7a14e 100644 --- a/bobbin/crates/xrpc/tests/aggregation.rs +++ b/bobbin/crates/xrpc/tests/aggregation.rs @@ -2233,7 +2233,7 @@ async fn profile_activity_returns_one_hydrated_aggregate() { .expect(1) .mount(&h.server) .await; - h.state = h.state.clone().with_mirror_v2(Some(Arc::new( + h.state = h.state.clone().with_mirror(Some(Arc::new( MirrorProxy::new( &Url::parse(&h.server.uri()).unwrap(), Arc::new(SystemClock::new()), diff --git a/bobbin/crates/xrpc/tests/mirror_v2_proxy.rs b/bobbin/crates/xrpc/tests/mirror_proxy.rs similarity index 99% rename from bobbin/crates/xrpc/tests/mirror_v2_proxy.rs rename to bobbin/crates/xrpc/tests/mirror_proxy.rs index f501f94c2..17bc437b7 100644 --- a/bobbin/crates/xrpc/tests/mirror_v2_proxy.rs +++ b/bobbin/crates/xrpc/tests/mirror_proxy.rs @@ -66,7 +66,7 @@ impl Harness { Arc::new(RepoIdResolver::detached(RuntimeHasher::default())), Arc::new(bobbin_xrpc::default_directory()), ) - .with_mirror_v2(Some(mirror_proxy)); + .with_mirror(Some(mirror_proxy)); Self { mirror, state } } diff --git a/bobbin/example.toml b/bobbin/example.toml index 4361e4acd..ffaa91965 100644 --- a/bobbin/example.toml +++ b/bobbin/example.toml @@ -193,13 +193,9 @@ #require_https = true [mirror] -# Can also be specified via environment variable `BOBBIN_MIRROR_URL`. -#url = - -[mirror_v2] -# Origin of a v2 mirror (gitmirror) XRPC server. +# Origin of the mirror (gitmirror) XRPC server. # -# Can also be specified via environment variable `BOBBIN_MIRROR_V2_URL`. +# Can also be specified via environment variable `BOBBIN_MIRROR_URL`. #url = [log] diff --git a/bobbin/worker/src/index.ts b/bobbin/worker/src/index.ts index 1afd31c6b..c260286e5 100644 --- a/bobbin/worker/src/index.ts +++ b/bobbin/worker/src/index.ts @@ -9,7 +9,6 @@ export interface Env { BOBBIN_HYDRANT_URL: string; BOBBIN_SLINGSHOT_URL: string; BOBBIN_MIRROR_URL: string; - BOBBIN_MIRROR_V2_URL?: string; BOBBIN_POCKET_URL?: string; BOBBIN_SERVICE_DID?: string; BOBBIN_LOG: string; @@ -94,7 +93,6 @@ export class BobbinContainer extends Container { BOBBIN_HYDRANT_URL: env.BOBBIN_HYDRANT_URL, BOBBIN_SLINGSHOT_URL: env.BOBBIN_SLINGSHOT_URL, BOBBIN_MIRROR_URL: env.BOBBIN_MIRROR_URL, - ...(env.BOBBIN_MIRROR_V2_URL ? { BOBBIN_MIRROR_V2_URL: env.BOBBIN_MIRROR_V2_URL } : {}), ...(env.BOBBIN_POCKET_URL ? { BOBBIN_POCKET_URL: env.BOBBIN_POCKET_URL } : {}), ...(env.BOBBIN_SERVICE_DID ? { BOBBIN_SERVICE_DID: env.BOBBIN_SERVICE_DID } : {}), BOBBIN_LOG: env.BOBBIN_LOG, diff --git a/bobbin/worker/wrangler.dev.jsonc b/bobbin/worker/wrangler.dev.jsonc index 052b1d65f..819ba2fff 100644 --- a/bobbin/worker/wrangler.dev.jsonc +++ b/bobbin/worker/wrangler.dev.jsonc @@ -55,7 +55,6 @@ "BOBBIN_HYDRANT_URL": "https://bobbin-svfe-dev.anirudh-s-account.workers.dev", "BOBBIN_SLINGSHOT_URL": "https://bobbin-svfe-dev.anirudh-s-account.workers.dev", "BOBBIN_MIRROR_URL": "https://mirror-fsn.tangled.network", - "BOBBIN_MIRROR_V2_URL": "https://mirror-fsn.tangled.network", "BOBBIN_POCKET_URL": "https://pocket.tangled.network", "BOBBIN_SERVICE_DID": "did:web:next.tangled.org", "BOBBIN_LOG": "info", diff --git a/docker-compose.yml b/docker-compose.yml index f9a6e6c64..495a329aa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -637,7 +637,7 @@ services: BOBBIN_SLINGSHOT_URL: http://hydrant:3000 BOBBIN_SERVICE_DID: did:web:bobbin.tngl.boltless.dev BOBBIN_KNOT_ALLOW_PRIVATE: "true" - BOBBIN_MIRROR_V2_URL: http://knotmirror:7000 + BOBBIN_MIRROR_URL: http://knotmirror:7000 BOBBIN_POCKET_URL: http://pocket:3000 BOBBIN_CODESEARCH_ZOEKT_URL: https://zoekt.tngl.boltless.dev BOBBIN_LOG: info -- 2.51.2