Centralize weather event and driver identifiers
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user