package pipeline import ( "context" "spider/internal/model" ) // Settings is a minimal interface satisfied by *service.SettingsService. // Using an interface here avoids an import cycle (service → worker → pipeline → service). type Settings interface { GetInt(ctx context.Context, key string, defaultVal int) int GetFloat(ctx context.Context, key string, defaultVal float64) float64 GetBool(ctx context.Context, key string, defaultVal bool) bool } // Phase 每个采集阶段的接口 type Phase interface { Name() string Run(ctx context.Context, task *model.Task, opts *Options) error } // Options Pipeline 执行选项(来自任务参数) type Options struct { Target string SkipPhases []string TestRun *TestRun } type TestRun struct { ItemLimit int MessageLimit int } // ProgressReporter 进度上报函数类型 // 由 pipeline.Runner 提供,各 phase 调用 type ProgressReporter func(phase string, current, total int, message string) // ShouldSkip 检查某阶段是否被跳过 func ShouldSkip(phaseName string, skipPhases []string) bool { for _, s := range skipPhases { if s == phaseName { return true } } return false }