From 5bd6b9b93cd52da2075bc00a08cf7feca4b85d5c Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 7 Jan 2026 11:40:41 +0000 Subject: Add SyncContext trait and MockSyncContext for purgatory sync Implement the abstraction layer for purgatory sync operations: - SyncContext trait: defines interface for repository data fetching, OID existence checks, git fetch operations, and event processing - ProcessResult: captures outcomes when releasing events from purgatory - MockSyncContext: test mock with builder pattern for configuring: - Clone URLs and which OIDs each URL provides - Needed OIDs (simulates purgatory state) - URL failure simulation - Fetch logging for assertions The trait uses async_trait for async method support and requires Send + Sync for use in concurrent sync operations. This abstraction enables unit testing of sync logic without I/O, while the real implementation (to be added later) will connect to actual database, git, and relay systems. --- src/purgatory/sync/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/purgatory/sync/mod.rs') diff --git a/src/purgatory/sync/mod.rs b/src/purgatory/sync/mod.rs index b29f10e..1ac0cb1 100644 --- a/src/purgatory/sync/mod.rs +++ b/src/purgatory/sync/mod.rs @@ -6,8 +6,13 @@ //! - Exponential backoff per identifier (20s → 2m, then 2m intervals) //! - Debouncing for burst event arrivals +mod context; mod queue; mod throttle; +pub use context::{ProcessResult, SyncContext}; pub use queue::SyncQueueEntry; pub use throttle::{DomainThrottle, ThrottleManager}; + +#[cfg(test)] +pub use context::mock::MockSyncContext; -- cgit v1.2.3