Weather service proxy support
All checks were successful
Build and Publish / release (push) Successful in 3m51s

This commit is contained in:
2025-01-12 17:23:32 -05:00
parent 7fc1fc9b56
commit 19823ea08f
13 changed files with 285 additions and 255 deletions

View File

@ -35,29 +35,6 @@ func (wu *WUProvider) ReqToWeather(_ context.Context, r *http.Request) (
return MapWUUpdate(wuUpdate), nil
}
func (wu *WUProvider) ProxyReq(ctx context.Context, update *weather.WeatherUpdate) error {
// tracer := otel.GetTracer(ctx, "wuProvider", "proxyReq")
// ctx, span := tracer.Start(ctx, "proxyToWunderground")
// defer span.End()
//
// resp, err := resty.New().R().
// SetContext(ctx).
// SetQueryParamsFromValues(r.URL.Query()).
// Get(wuURL)
// if err != nil {
// span.SetStatus(codes.Error, err.Error())
// span.RecordError(err)
// }
//
// span.SetAttributes(
// attribute.Int("statusCode", resp.StatusCode()),
// attribute.String("body", string(resp.Body())),
// )
//
// return err
return nil
}
func MapWUUpdate(wuUpdate *WundergroundUpdate) *weather.WeatherUpdate {
updateTime := time.Now()
@ -68,32 +45,25 @@ func MapWUUpdate(wuUpdate *WundergroundUpdate) *weather.WeatherUpdate {
}
}
credentials := make(map[string]string)
if wuUpdate.ID != nil && wuUpdate.Password != nil {
credentials["ID"] = *wuUpdate.ID
credentials["Password"] = *wuUpdate.Password
}
return &weather.WeatherUpdate{
DateUTC: &updateTime,
StationID: wuUpdate.ID,
StationType: wuUpdate.SoftwareType,
TempOutdoorF: wuUpdate.Tempf,
HumidityOudoor: wuUpdate.Humidity,
WindSpeedMPH: wuUpdate.WindGustMPH,
WindGustMPH: wuUpdate.WindGustMPH,
WindDir: wuUpdate.WindDir,
UV: wuUpdate.UV,
SolarRadiation: wuUpdate.SolarRadiation,
HourlyRainIn: wuUpdate.RainIn,
DailyRainIn: wuUpdate.DailyRainIn,
WeeklyRainIn: wuUpdate.WeeklyRainIn,
MonthlyRainIn: wuUpdate.MonthlyRainIn,
YearlyRainIn: wuUpdate.YearlyRainIn,
TempIndoorF: wuUpdate.IndoorTempF,
HumidityIndoor: wuUpdate.IndoorHumidity,
BaromRelativeIn: wuUpdate.BaromIn,
WeatherServiceCredentials: credentials,
DateUTC: &updateTime,
StationID: wuUpdate.ID,
StationType: wuUpdate.SoftwareType,
TempOutdoorF: wuUpdate.Tempf,
HumidityOudoor: wuUpdate.Humidity,
WindSpeedMPH: wuUpdate.WindGustMPH,
WindGustMPH: wuUpdate.WindGustMPH,
WindDir: wuUpdate.WindDir,
UV: wuUpdate.UV,
SolarRadiation: wuUpdate.SolarRadiation,
HourlyRainIn: wuUpdate.RainIn,
DailyRainIn: wuUpdate.DailyRainIn,
WeeklyRainIn: wuUpdate.WeeklyRainIn,
MonthlyRainIn: wuUpdate.MonthlyRainIn,
YearlyRainIn: wuUpdate.YearlyRainIn,
TempIndoorF: wuUpdate.IndoorTempF,
HumidityIndoor: wuUpdate.IndoorHumidity,
BaromRelativeIn: wuUpdate.BaromIn,
}
}