Plumb ctx through classifier and Ollama HTTP path
OllamaClient.Generate/GenerateText/call now take ctx and build the HTTP request via NewRequestWithContext, so an in-flight LLM call is aborted when the parent context is cancelled (Ctrl-C). Classifier.Classify and its tier helpers take ctx too. ProcessFunc gets a ctx parameter so the poller can forward its cancellable context down to classification. Explainer.summarize manages its own 60s context since reaction-driven flow has no parent ctx to inherit.
This commit is contained in:
@@ -12,7 +12,9 @@ import (
|
||||
)
|
||||
|
||||
// ProcessFunc is called for each new feed item that needs classification.
|
||||
type ProcessFunc func(item *FeedItem)
|
||||
// ctx is the poller's parent context; callbacks should pass it into any
|
||||
// downstream LLM/HTTP work so shutdown aborts in-flight calls.
|
||||
type ProcessFunc func(ctx context.Context, item *FeedItem)
|
||||
|
||||
// Poller manages per-source RSS polling goroutines.
|
||||
type Poller struct {
|
||||
@@ -182,7 +184,7 @@ func (p *Poller) pollOnceWithErr(ctx context.Context, src config.SourceConfig) e
|
||||
continue
|
||||
}
|
||||
|
||||
p.process(&items[i])
|
||||
p.process(ctx, &items[i])
|
||||
newCount++
|
||||
}
|
||||
|
||||
@@ -212,7 +214,7 @@ func (p *Poller) pollOnceWithErr(ctx context.Context, src config.SourceConfig) e
|
||||
continue
|
||||
}
|
||||
|
||||
p.process(&FeedItem{
|
||||
p.process(ctx, &FeedItem{
|
||||
GUID: s.GUID,
|
||||
Headline: s.Headline,
|
||||
Lede: s.Lede,
|
||||
|
||||
Reference in New Issue
Block a user