Files
weatherfeeder/internal/sources/nws/alerts.go

40 lines
1.2 KiB
Go

package nws
import (
"context"
"fmt"
"gitea.maximumdirect.net/ejr/feedkit/config"
"gitea.maximumdirect.net/ejr/feedkit/event"
"gitea.maximumdirect.net/ejr/weatherfeeder/internal/sources/common"
)
// AlertsSource polls an NWS alerts endpoint and will emit RAW alert Events.
// For now Poll remains TODO; this file just migrates to the shared HTTPSource spine.
type AlertsSource struct {
http *common.HTTPSource
}
func NewAlertsSource(cfg config.SourceConfig) (*AlertsSource, error) {
const driver = "nws_alerts"
// NWS APIs are typically GeoJSON; allow fallback to plain JSON as well.
hs, err := common.NewHTTPSource(driver, cfg, "application/geo+json, application/json")
if err != nil {
return nil, err
}
return &AlertsSource{http: hs}, nil
}
func (s *AlertsSource) Name() string { return s.http.Name }
// Kind is used for routing/policy.
// The envelope type is event.Event; payload will eventually normalize into model.WeatherAlert.
func (s *AlertsSource) Kind() event.Kind { return event.Kind("alert") }
func (s *AlertsSource) Poll(ctx context.Context) ([]event.Event, error) {
_ = ctx
return nil, fmt.Errorf("nws.AlertsSource.Poll: TODO implement")
}