package provider import ( "context" "time" "proxy-pool/internal/domain/activitypool" proxyDomain "proxy-pool/internal/domain/proxy" "proxy-pool/internal/domain/upstream" ) type FetchResponse struct { // Body belongs to the caller until Parse returns and must not be reused earlier. Body []byte RetryAfter time.Duration } // ProviderAdapter may be called concurrently up to Config.MaxInFlight times. type ProviderAdapter interface { Fetch(context.Context) (FetchResponse, error) } // RetryableError lets an adapter stop retries for permanent provider failures. // Plain errors are treated as transient for backward-compatible fail-safe retries. type RetryableError interface { error Retryable() bool } // Parser must be safe for concurrent calls and must honor context cancellation. type Parser interface { Parse(context.Context, []byte) ([]proxyDomain.Proxy, error) } type Result struct { UpstreamID string Class upstream.FetchClass ValidCount int NewCount int Err error Attempt int } type ResultRecorder interface { // Record may be called concurrently and must not retain mutable result data. Record(Result) } type Ports struct { Adapter ProviderAdapter Parser Parser Activity activitypool.Upserter Results ResultRecorder Capacity upstream.FetchCapacity }