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

36
sinks/stdout.go Normal file
View File

@@ -0,0 +1,36 @@
package sinks
import (
"context"
"encoding/json"
"fmt"
"gitea.maximumdirect.net/ejr/feedkit/event"
)
type StdoutSink struct{ name string }
func NewStdoutSink(name string) *StdoutSink {
return &StdoutSink{name: name}
}
func (s *StdoutSink) Name() string { return s.name }
func (s *StdoutSink) Consume(ctx context.Context, e event.Event) error {
_ = ctx
// Boundary validation: if something upstream violated invariants,
// surface it loudly rather than printing partial nonsense.
if err := e.Validate(); err != nil {
return fmt.Errorf("stdout sink: invalid event: %w", err)
}
// Generic default: one JSON line per event.
// This makes stdout useful across all domains and easy to pipe into jq / logs.
b, err := json.Marshal(e)
if err != nil {
return fmt.Errorf("stdout sink: marshal event: %w", err)
}
fmt.Println(string(b))
return nil
}