47 lines
2.4 KiB
Go
47 lines
2.4 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/weatherfeeder/internal/sources/spc"
|
|
|
|
"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.DriverObservation, factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return nws.NewObservationSource(cfg) }},
|
|
{driver: nws.DriverAlerts, factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return nws.NewAlertsSource(cfg) }},
|
|
{driver: nws.DriverForecastHourly, factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return nws.NewHourlyForecastSource(cfg) }},
|
|
{driver: nws.DriverForecastNarrative, factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return nws.NewNarrativeForecastSource(cfg) }},
|
|
{driver: nws.DriverForecastDiscussion, factory: func(cfg config.SourceConfig) (fksource.PollSource, error) {
|
|
return nws.NewForecastDiscussionSource(cfg)
|
|
}},
|
|
{driver: nws.DriverWeatherStories, factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return nws.NewWeatherStoriesSource(cfg) }},
|
|
{driver: openmeteo.DriverObservation, factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return openmeteo.NewObservationSource(cfg) }},
|
|
{driver: openmeteo.DriverForecast, factory: func(cfg config.SourceConfig) (fksource.PollSource, error) { return openmeteo.NewForecastSource(cfg) }},
|
|
{driver: openweather.DriverObservation, factory: func(cfg config.SourceConfig) (fksource.PollSource, error) {
|
|
return openweather.NewObservationSource(cfg)
|
|
}},
|
|
{driver: spc.DriverConvectiveOutlook, factory: func(cfg config.SourceConfig) (fksource.PollSource, error) {
|
|
return spc.NewConvectiveOutlookSource(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)
|
|
})
|
|
}
|
|
}
|