From 3dfec1e449f260295e8c5c505dd1edb82d787c58 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 7 Jan 2026 14:19:27 +0000 Subject: Wire up new purgatory sync loop, remove legacy sync_state_git_data Phase 13 of purgatory-sync-redesign: - Add sync loop startup in main.rs (RealSyncContext + ThrottleManager + start_sync_loop) - Update add_state() and add_pr() to automatically enqueue for background sync - Remove start_state_sync() call from state.rs (now handled by sync loop) - Remove orphaned legacy functions: sync_state_git_data, fetch_missing_oids_from_server, get_most_complete_local_repo, identify_missing_oids, get_date_of_most_recent_commit_on_default_branch - Clean up unused imports in purgatory/mod.rs --- src/main.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 59edc09..b4a42af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use ngit_grasp::{ git, http, metrics::Metrics, nostr, - purgatory::Purgatory, + purgatory::{sync::RealSyncContext, sync::ThrottleManager, Purgatory}, sync::SyncManager, }; @@ -111,6 +111,24 @@ async fn main() -> Result<()> { }); info!("Purgatory cleanup task started (60s interval)"); + // Start purgatory sync loop for background git data fetching + let sync_ctx = Arc::new(RealSyncContext::new( + purgatory.clone(), + relay_with_db.database.clone(), + PathBuf::from(config.effective_git_data_path()), + Some(config.domain.clone()), + Some(relay_with_db.relay.clone()), + )); + + // Create throttle manager for rate limiting remote git servers + // Default: 5 concurrent requests per domain, 30 requests per minute per domain + let throttle_manager = Arc::new(ThrottleManager::new(5, 30)); + throttle_manager.set_context(sync_ctx.clone()); + + // Start the sync loop + let _sync_loop_handle = purgatory.clone().start_sync_loop(sync_ctx, throttle_manager); + info!("Purgatory sync loop started (1s interval)"); + // Setup shutdown handler for purgatory cleanup let shutdown_purgatory = purgatory.clone(); let git_data_path = config.effective_git_data_path(); -- cgit v1.2.3