···1616use std::sync::{Arc, Mutex, atomic::Ordering};
1717use std::time::{Duration, Instant, SystemTime};
18181919-use super::ResyncError;
1919+use super::{AppStuff, ResyncError};
20202121use tokio::task::{Id as TaskId, JoinSet};
2222use tracing::{debug, error, info, trace, warn};
···182182 }
183183 }
184184185185- let client = client.clone();
186186- let resolver = resolver.clone();
187187- let db = db.clone();
188188- let token = token.clone();
185185+ let worker_stuff = AppStuff {
186186+ resolver: resolver.clone(),
187187+ client: client.clone(),
188188+ db: db.clone(),
189189+ token: token.clone(),
190190+ };
189191 let handle = workers.spawn(async move {
190192 run_worker(
191193 item,
192192- &resolver,
193193- &client,
194194- &db,
195195- token,
194194+ worker_stuff,
196195 describe_timeout,
197196 get_repo_timeout,
198197 force_get_repo,
···371370372371async fn run_worker(
373372 item: ResyncItem,
374374- resolver: &crate::identity::Resolver,
375375- client: &crate::http::ThrottledClient,
376376- db: &DbRef,
377377- token: tokio_util::sync::CancellationToken,
373373+ app_stuff: AppStuff,
378374 describe_timeout: std::time::Duration,
379375 get_repo_timeout: std::time::Duration,
380376 force_get_repo: bool,
381377) -> WorkerOutcome {
382378 let did = item.did.clone();
383379 match super::index_repo(
384384- client,
385385- resolver,
380380+ app_stuff.clone(),
386381 item.did,
387387- db,
388388- token,
389382 describe_timeout,
390383 get_repo_timeout,
391384 force_get_repo,
···406399 Err(ResyncError::RepoNotFound) => {
407400 // Invalidate the cached DID resolution: the PDS pointer may be
408401 // stale (e.g. mid-migration), so the next attempt will re-resolve.
409409- resolver.invalidate_did(&did);
402402+ app_stuff.resolver.invalidate_did(&did);
410403 info!(did = %did, "repo not found on PDS; invalidated DID cache");
411404 WorkerOutcome::NotFound {
412405 retry_count: item.retry_count,
+20-10
src/sync/resync/mod.rs
···113113 Deactivated,
114114}
115115116116+/// Bundle of useful stuff from the app
117117+///
118118+/// should probably become a proper AppState
119119+#[derive(Clone)]
120120+pub struct AppStuff {
121121+ resolver: Arc<crate::identity::Resolver>,
122122+ client: crate::http::ThrottledClient,
123123+ db: DbRef,
124124+ token: tokio_util::sync::CancellationToken,
125125+}
126126+116127/// Establish the current collection set for `did` and write it to the index.
117128///
118129/// Tries `describeRepo` first (cheap). Falls back to a full `getRepo` CAR walk
···120131///
121132/// Returns `Ok(())` silently if the repo is not found or inaccessible;
122133/// the caller decides whether to retry on transient errors.
123123-pub async fn index_repo<C>(
124124- client: &C,
125125- resolver: &crate::identity::Resolver,
134134+pub async fn index_repo(
135135+ AppStuff {
136136+ resolver,
137137+ client,
138138+ db,
139139+ token,
140140+ }: AppStuff,
126141 did: Did<'_>,
127127- db: &DbRef,
128128- token: tokio_util::sync::CancellationToken,
129142 describe_timeout: Duration,
130143 get_repo_timeout: Duration,
131144 force_get_repo: bool,
132132-) -> Result<()>
133133-where
134134- C: HttpClient + HttpClientExt + Sync,
135135-{
145145+) -> Result<()> {
136146 // Own the DID for the duration of the function so we can move it into
137147 // spawn_blocking closures (which require 'static captures).
138148 let did: Did<'static> = did.into_static();
···141151 let base = &*resolved.pds;
142152143153 let repo_snapshot = match fetch_collections(
144144- client,
154154+ &client,
145155 base,
146156 did.clone(),
147157 token,