Centralize weather event and driver identifiers

This commit is contained in:
2026-06-11 02:08:36 +00:00
parent dec05821bf
commit b7277e0c02
31 changed files with 162 additions and 119 deletions

View File

@@ -20,8 +20,6 @@ import (
)
const (
driverConvectiveOutlook = "spc_convective_outlook"
acceptGeoJSON = "application/geo+json, application/json"
acceptDiscussion = "text/html, application/xhtml+xml"
acceptRSS = "application/rss+xml, application/xml, text/xml"
@@ -58,24 +56,24 @@ type ConvectiveOutlookSource struct {
func NewConvectiveOutlookSource(cfg config.SourceConfig) (*ConvectiveOutlookSource, error) {
name := strings.TrimSpace(cfg.Name)
if name == "" {
return nil, fmt.Errorf("%s: name is required", driverConvectiveOutlook)
return nil, fmt.Errorf("%s: name is required", DriverConvectiveOutlook)
}
if cfg.Params == nil {
return nil, fmt.Errorf("%s %q: params are required", driverConvectiveOutlook, name)
return nil, fmt.Errorf("%s %q: params are required", DriverConvectiveOutlook, name)
}
userAgent, ok := cfg.ParamString("user_agent", "userAgent")
if !ok {
return nil, fmt.Errorf("%s %q: params.user_agent is required", driverConvectiveOutlook, name)
return nil, fmt.Errorf("%s %q: params.user_agent is required", DriverConvectiveOutlook, name)
}
latitude, err := requireFloatParam(cfg, "latitude")
if err != nil {
return nil, fmt.Errorf("%s %q: %w", driverConvectiveOutlook, name, err)
return nil, fmt.Errorf("%s %q: %w", DriverConvectiveOutlook, name, err)
}
longitude, err := requireFloatParam(cfg, "longitude")
if err != nil {
return nil, fmt.Errorf("%s %q: %w", driverConvectiveOutlook, name, err)
return nil, fmt.Errorf("%s %q: %w", DriverConvectiveOutlook, name, err)
}
timeout := transport.DefaultHTTPTimeout
@@ -98,11 +96,11 @@ func NewConvectiveOutlookSource(cfg config.SourceConfig) (*ConvectiveOutlookSour
geoJSONProducts, err := configuredGeoJSONProducts(cfg)
if err != nil {
return nil, fmt.Errorf("%s %q: %w", driverConvectiveOutlook, name, err)
return nil, fmt.Errorf("%s %q: %w", DriverConvectiveOutlook, name, err)
}
discussions, err := configuredDiscussionProducts(cfg)
if err != nil {
return nil, fmt.Errorf("%s %q: %w", driverConvectiveOutlook, name, err)
return nil, fmt.Errorf("%s %q: %w", DriverConvectiveOutlook, name, err)
}
rssURL := ""
@@ -131,7 +129,7 @@ func NewConvectiveOutlookSource(cfg config.SourceConfig) (*ConvectiveOutlookSour
func (s *ConvectiveOutlookSource) Name() string { return s.name }
func (s *ConvectiveOutlookSource) Kinds() []event.Kind {
return []event.Kind{event.Kind("outlook")}
return []event.Kind{event.Kind(standards.KindOutlook)}
}
func (s *ConvectiveOutlookSource) Poll(ctx context.Context) ([]event.Event, error) {
@@ -221,7 +219,7 @@ func (s *ConvectiveOutlookSource) Poll(ctx context.Context) ([]event.Event, erro
eventID := fksources.DefaultEventID("", s.name, &effectiveAt, emittedAt)
return fksources.SingleEvent(
event.Kind("outlook"),
event.Kind(standards.KindOutlook),
s.name,
standards.SchemaRawSPCConvectiveOutlookV1,
eventID,