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

33
sinks/registry.go Normal file
View File

@@ -0,0 +1,33 @@
package sinks
import (
"fmt"
"gitea.maximumdirect.net/ejr/feedkit/config"
)
// Factory constructs a sink instance from config.
//
// This is the mechanism that lets concrete daemons wire in whatever sinks they
// want without main.go being full of switch statements.
type Factory func(cfg config.SinkConfig) (Sink, error)
type Registry struct {
byDriver map[string]Factory
}
func NewRegistry() *Registry {
return &Registry{byDriver: map[string]Factory{}}
}
func (r *Registry) Register(driver string, f Factory) {
r.byDriver[driver] = f
}
func (r *Registry) Build(cfg config.SinkConfig) (Sink, error) {
f, ok := r.byDriver[cfg.Driver]
if !ok {
return nil, fmt.Errorf("unknown sink driver: %q", cfg.Driver)
}
return f(cfg)
}