normalizers: added a structure for normalizers; refactoring sources -> sources+normalizers is still todo.
This commit is contained in:
37
internal/normalizers/builtins.go
Normal file
37
internal/normalizers/builtins.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// FILE: ./internal/normalizers/builtins.go
|
||||
package normalizers
|
||||
|
||||
import (
|
||||
fknormalize "gitea.maximumdirect.net/ejr/feedkit/normalize"
|
||||
|
||||
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/normalizers/nws"
|
||||
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/normalizers/openmeteo"
|
||||
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/normalizers/openweather"
|
||||
)
|
||||
|
||||
// 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)
|
||||
//
|
||||
// Registration order matters because feedkit normalize.Registry is “first match wins”.
|
||||
// In weatherfeeder we avoid ambiguity by matching strictly on schema constants, but
|
||||
// we still keep ordering stable as a best practice.
|
||||
//
|
||||
// If reg is nil, this function is a no-op.
|
||||
func RegisterBuiltins(reg *fknormalize.Registry) {
|
||||
if reg == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 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.
|
||||
nws.Register(reg)
|
||||
openmeteo.Register(reg)
|
||||
openweather.Register(reg)
|
||||
}
|
||||
Reference in New Issue
Block a user