Centralize weather event and driver identifiers
This commit is contained in:
@@ -19,9 +19,7 @@ type ObservationSource struct {
|
||||
}
|
||||
|
||||
func NewObservationSource(cfg config.SourceConfig) (*ObservationSource, error) {
|
||||
const driver = "openweather_observation"
|
||||
|
||||
hs, err := fksources.NewHTTPSource(driver, cfg, "application/json")
|
||||
hs, err := fksources.NewHTTPSource(DriverObservation, cfg, "application/json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -35,7 +33,9 @@ func NewObservationSource(cfg config.SourceConfig) (*ObservationSource, error) {
|
||||
|
||||
func (s *ObservationSource) Name() string { return s.http.Name }
|
||||
|
||||
func (s *ObservationSource) Kinds() []event.Kind { return []event.Kind{event.Kind("observation")} }
|
||||
func (s *ObservationSource) Kinds() []event.Kind {
|
||||
return []event.Kind{event.Kind(standards.KindObservation)}
|
||||
}
|
||||
|
||||
func (s *ObservationSource) Poll(ctx context.Context) ([]event.Event, error) {
|
||||
if err := owcommon.RequireMetricUnits(s.http.URL); err != nil {
|
||||
@@ -60,7 +60,7 @@ func (s *ObservationSource) Poll(ctx context.Context) ([]event.Event, error) {
|
||||
eventID := fksources.DefaultEventID("", s.http.Name, effectiveAt, emittedAt)
|
||||
|
||||
return fksources.SingleEvent(
|
||||
event.Kind("observation"),
|
||||
event.Kind(standards.KindObservation),
|
||||
s.http.Name,
|
||||
standards.SchemaRawOpenWeatherCurrentV1,
|
||||
eventID,
|
||||
|
||||
Reference in New Issue
Block a user