diff options
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(); |