All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
42 lines
2.0 KiB
Go
42 lines
2.0 KiB
Go
package sources
|
|
|
|
import (
|
|
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/sources/nws"
|
|
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/sources/openmeteo"
|
|
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/sources/openweather"
|
|
|
|
"gitea.maximumdirect.net/ejr/feedkit/config"
|
|
fksource "gitea.maximumdirect.net/ejr/feedkit/sources"
|
|
)
|
|
|
|
type pollDriverRegistration struct {
|
|
driver string
|
|
factory func(config.SourceConfig) (fksource.PollSource, error)
|
|
}
|
|
|
|
var pollDriverRegistrations = []pollDriverRegistration{
|
|
{driver: "nws_observation", factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return nws.NewObservationSource(cfg) }},
|
|
{driver: "nws_alerts", factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return nws.NewAlertsSource(cfg) }},
|
|
{driver: "nws_forecast_hourly", factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return nws.NewHourlyForecastSource(cfg) }},
|
|
{driver: "nws_forecast_narrative", factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return nws.NewNarrativeForecastSource(cfg) }},
|
|
{driver: "nws_forecast_discussion", factory: func(cfg config.SourceConfig) (fksource.PollSource, error) {
|
|
return nws.NewForecastDiscussionSource(cfg)
|
|
}},
|
|
{driver: "openmeteo_observation", factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return openmeteo.NewObservationSource(cfg) }},
|
|
{driver: "openmeteo_forecast", factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return openmeteo.NewForecastSource(cfg) }},
|
|
{driver: "openweather_observation", factory: func(cfg config.SourceConfig) (fksource.PollSource, error) {
|
|
return openweather.NewObservationSource(cfg)
|
|
}},
|
|
}
|
|
|
|
// RegisterBuiltins registers the source drivers that ship with this binary.
|
|
// Keeping this in one place makes main.go very readable.
|
|
func RegisterBuiltins(r *fksource.Registry) {
|
|
for _, reg := range pollDriverRegistrations {
|
|
reg := reg
|
|
r.RegisterPoll(reg.driver, func(cfg config.SourceConfig) (fksource.PollSource, error) {
|
|
return reg.factory(cfg)
|
|
})
|
|
}
|
|
}
|