diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-07 14:19:27 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-07 14:46:17 +0000 |
| commit | 3dfec1e449f260295e8c5c505dd1edb82d787c58 (patch) | |
| tree | f093ebfd02cbc16ca2c3c36f98601a78cf0876fd /src/main.rs | |
| parent | 74979c1de32f69a39e0e290f56435ef687c2b6f6 (diff) | |
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
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 20 |
1 files changed, 19 insertions, 1 deletions
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::{ | |||
| 11 | git, http, | 11 | git, http, |
| 12 | metrics::Metrics, | 12 | metrics::Metrics, |
| 13 | nostr, | 13 | nostr, |
| 14 | purgatory::Purgatory, | 14 | purgatory::{sync::RealSyncContext, sync::ThrottleManager, Purgatory}, |
| 15 | sync::SyncManager, | 15 | sync::SyncManager, |
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| @@ -111,6 +111,24 @@ async fn main() -> Result<()> { | |||
| 111 | }); | 111 | }); |
| 112 | info!("Purgatory cleanup task started (60s interval)"); | 112 | info!("Purgatory cleanup task started (60s interval)"); |
| 113 | 113 | ||
| 114 | // Start purgatory sync loop for background git data fetching | ||
| 115 | let sync_ctx = Arc::new(RealSyncContext::new( | ||
| 116 | purgatory.clone(), | ||
| 117 | relay_with_db.database.clone(), | ||
| 118 | PathBuf::from(config.effective_git_data_path()), | ||
| 119 | Some(config.domain.clone()), | ||
| 120 | Some(relay_with_db.relay.clone()), | ||
| 121 | )); | ||
| 122 | |||
| 123 | // Create throttle manager for rate limiting remote git servers | ||
| 124 | // Default: 5 concurrent requests per domain, 30 requests per minute per domain | ||
| 125 | let throttle_manager = Arc::new(ThrottleManager::new(5, 30)); | ||
| 126 | throttle_manager.set_context(sync_ctx.clone()); | ||
| 127 | |||
| 128 | // Start the sync loop | ||
| 129 | let _sync_loop_handle = purgatory.clone().start_sync_loop(sync_ctx, throttle_manager); | ||
| 130 | info!("Purgatory sync loop started (1s interval)"); | ||
| 131 | |||
| 114 | // Setup shutdown handler for purgatory cleanup | 132 | // Setup shutdown handler for purgatory cleanup |
| 115 | let shutdown_purgatory = purgatory.clone(); | 133 | let shutdown_purgatory = purgatory.clone(); |
| 116 | let git_data_path = config.effective_git_data_path(); | 134 | let git_data_path = config.effective_git_data_path(); |