2026-01-14 10:35:16 -06:00
|
|
|
// FILE: ./internal/normalizers/builtins.go
|
|
|
|
|
package normalizers
|
|
|
|
|
|
|
|
|
|
import (
|
2026-03-16 18:35:44 -05:00
|
|
|
fknormalize "gitea.maximumdirect.net/ejr/feedkit/processors/normalize"
|
2026-01-14 10:35:16 -06:00
|
|
|
|
|
|
|
|
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/normalizers/nws"
|
|
|
|
|
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/normalizers/openmeteo"
|
|
|
|
|
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/normalizers/openweather"
|
2026-06-11 00:20:31 +00:00
|
|
|
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/normalizers/spc"
|
2026-01-14 10:35:16 -06:00
|
|
|
)
|
|
|
|
|
|
2026-03-28 12:01:07 -05:00
|
|
|
var builtinRegistrations = []func([]fknormalize.Normalizer) []fknormalize.Normalizer{
|
|
|
|
|
nws.Register,
|
|
|
|
|
openmeteo.Register,
|
|
|
|
|
openweather.Register,
|
2026-06-11 00:20:31 +00:00
|
|
|
spc.Register,
|
2026-03-28 12:01:07 -05:00
|
|
|
}
|
|
|
|
|
|
2026-01-14 10:35:16 -06:00
|
|
|
// RegisterBuiltins registers all normalizers shipped with this binary.
|
|
|
|
|
//
|
|
|
|
|
// This mirrors internal/sources.RegisterBuiltins, but note the selection model:
|
|
|
|
|
//
|
|
|
|
|
// - sources are built by name (cfg.Driver -> factory)
|
|
|
|
|
// - normalizers are selected by Match() (event.Schema -> first match wins)
|
|
|
|
|
//
|
2026-03-16 13:35:51 -05:00
|
|
|
// Registration order matters because feedkit normalize.Processor is "first match wins".
|
2026-01-14 10:35:16 -06:00
|
|
|
// In weatherfeeder we avoid ambiguity by matching strictly on schema constants, but
|
|
|
|
|
// we still keep ordering stable as a best practice.
|
2026-03-16 13:35:51 -05:00
|
|
|
func RegisterBuiltins(in []fknormalize.Normalizer) []fknormalize.Normalizer {
|
|
|
|
|
out := in
|
2026-01-14 10:35:16 -06:00
|
|
|
|
|
|
|
|
// Keep this intentionally boring: delegate registration to provider subpackages
|
|
|
|
|
// so main.go stays clean and each provider owns its own mapping logic.
|
|
|
|
|
//
|
|
|
|
|
// Order here should be stable across releases to reduce surprises when adding
|
|
|
|
|
// new normalizers.
|
2026-03-28 12:01:07 -05:00
|
|
|
for _, register := range builtinRegistrations {
|
|
|
|
|
out = register(out)
|
|
|
|
|
}
|
2026-03-16 13:35:51 -05:00
|
|
|
|
|
|
|
|
return out
|
2026-01-14 10:35:16 -06:00
|
|
|
}
|