feedkit: split the former maximumdirect.net/weatherd project in two.

feedkit now contains a reusable core, while weatherfeeder is a concrete implementation that includes weather-specific functions.
This commit is contained in:
2026-01-13 10:40:01 -06:00
parent 977b81e647
commit 0cc2862170
26 changed files with 1553 additions and 0 deletions

43
pipeline/pipeline.go Normal file
View File

@@ -0,0 +1,43 @@
package pipeline
import (
"context"
"fmt"
"gitea.maximumdirect.net/ejr/feedkit/event"
)
// Processor can mutate/drop events (dedupe, rate-limit, normalization tweaks).
type Processor interface {
Process(ctx context.Context, in event.Event) (out *event.Event, err error)
}
type Pipeline struct {
Processors []Processor
}
func (p *Pipeline) Process(ctx context.Context, e event.Event) (*event.Event, error) {
if err := e.Validate(); err != nil {
return nil, fmt.Errorf("pipeline: invalid input event: %w", err)
}
cur := &e
for _, proc := range p.Processors {
out, err := proc.Process(ctx, *cur)
if err != nil {
return nil, err
}
if out == nil {
// Dropped by policy.
return nil, nil
}
cur = out
}
if err := cur.Validate(); err != nil {
return nil, fmt.Errorf("pipeline: invalid output event: %w", err)
}
return cur, nil
}