refactor: implement worker pool pattern, add persistent task queue, and decouple target loading logic
This commit is contained in:
@@ -21,14 +21,17 @@ func NewPipeline(filters ...JobFilter) *FilterPipeline {
|
||||
return &FilterPipeline{filters: filters}
|
||||
}
|
||||
|
||||
func (p *FilterPipeline) Execute(ctx context.Context, title, rawContent string) (bool, float64) {
|
||||
func (p *FilterPipeline) Execute(ctx context.Context, title, rawContent string) (bool, float64, string) {
|
||||
var totalScore float64
|
||||
for _, f := range p.filters {
|
||||
res, err := f.Process(ctx, title, rawContent)
|
||||
if err != nil || !res.Keep {
|
||||
return false, 0
|
||||
if err != nil {
|
||||
return false, 0, err.Error()
|
||||
}
|
||||
if !res.Keep {
|
||||
return false, 0, res.Reason
|
||||
}
|
||||
totalScore += res.Score
|
||||
}
|
||||
return true, totalScore
|
||||
return true, totalScore, ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user