Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
f079d106a1 | |||
fc2d05e957 | |||
59f5bfbba1 | |||
0adab13221 | |||
3b0748da25 | |||
2d683e61b0 | |||
82bc3acfc3 |
9
TODO.md
9
TODO.md
@ -1,10 +1,15 @@
|
|||||||
|
# Issues
|
||||||
|
- [x] Redis recorder panic
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
- [ ] Add json schema for config
|
- [ ] Add json schema to CI and README
|
||||||
- [ ] Finish implementing weather GRPC
|
|
||||||
- [ ] Update README
|
- [ ] Update README
|
||||||
- [ ] Add Grafana dashboard
|
- [ ] Add Grafana dashboard
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
- [x] Stop Marshaling sensors / batteries with no data
|
||||||
|
- [x] Finish implementing weather GRPC
|
||||||
|
- [x] Add json schema for config
|
||||||
- [x] Add new spans
|
- [x] Add new spans
|
||||||
- [x] Helm Chart
|
- [x] Helm Chart
|
||||||
- [x] Add proxy to upstream support
|
- [x] Add proxy to upstream support
|
||||||
|
@ -207,6 +207,7 @@ type WeatherUpdate struct {
|
|||||||
DewPointF *float64 `protobuf:"fixed64,25,opt,name=dew_point_f,json=dewPointF,proto3,oneof" json:"dew_point_f,omitempty"`
|
DewPointF *float64 `protobuf:"fixed64,25,opt,name=dew_point_f,json=dewPointF,proto3,oneof" json:"dew_point_f,omitempty"`
|
||||||
WindChillF *float64 `protobuf:"fixed64,26,opt,name=wind_chill_f,json=windChillF,proto3,oneof" json:"wind_chill_f,omitempty"`
|
WindChillF *float64 `protobuf:"fixed64,26,opt,name=wind_chill_f,json=windChillF,proto3,oneof" json:"wind_chill_f,omitempty"`
|
||||||
TempHumiditySensors []*TempHumiditySensor `protobuf:"bytes,27,rep,name=temp_humidity_sensors,json=tempHumiditySensors,proto3" json:"temp_humidity_sensors,omitempty"`
|
TempHumiditySensors []*TempHumiditySensor `protobuf:"bytes,27,rep,name=temp_humidity_sensors,json=tempHumiditySensors,proto3" json:"temp_humidity_sensors,omitempty"`
|
||||||
|
UpdateTimestamp *timestamppb.Timestamp `protobuf:"bytes,28,opt,name=update_timestamp,json=updateTimestamp,proto3" json:"update_timestamp,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@ -430,6 +431,13 @@ func (x *WeatherUpdate) GetTempHumiditySensors() []*TempHumiditySensor {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *WeatherUpdate) GetUpdateTimestamp() *timestamppb.Timestamp {
|
||||||
|
if x != nil {
|
||||||
|
return x.UpdateTimestamp
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Represents a temperature and humidity sensor
|
// Represents a temperature and humidity sensor
|
||||||
type TempHumiditySensor struct {
|
type TempHumiditySensor struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
@ -576,7 +584,7 @@ var file_weather_weather_proto_rawDesc = string([]byte{
|
|||||||
0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x74,
|
0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x74,
|
||||||
0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x73,
|
0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x73,
|
||||||
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x0f, 0x0a, 0x0d, 0x5f,
|
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x0f, 0x0a, 0x0d, 0x5f,
|
||||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x22, 0xb7, 0x0c, 0x0a,
|
0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x22, 0xfe, 0x0c, 0x0a,
|
||||||
0x0d, 0x57, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x21,
|
0x0d, 0x57, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x21,
|
||||||
0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
|
0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d,
|
||||||
@ -651,51 +659,56 @@ var file_weather_weather_proto_rawDesc = string([]byte{
|
|||||||
0x65, 0x6e, 0x74, 0x2e, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x6d, 0x70,
|
0x65, 0x6e, 0x74, 0x2e, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x6d, 0x70,
|
||||||
0x48, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x52, 0x13,
|
0x48, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x52, 0x13,
|
||||||
0x74, 0x65, 0x6d, 0x70, 0x48, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x53, 0x65, 0x6e, 0x73,
|
0x74, 0x65, 0x6d, 0x70, 0x48, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x53, 0x65, 0x6e, 0x73,
|
||||||
0x6f, 0x72, 0x73, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x6f, 0x75, 0x74,
|
0x6f, 0x72, 0x73, 0x12, 0x45, 0x0a, 0x10, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69,
|
||||||
0x64, 0x6f, 0x6f, 0x72, 0x5f, 0x66, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x5f,
|
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e,
|
||||||
0x69, 0x6e, 0x64, 0x6f, 0x6f, 0x72, 0x5f, 0x66, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x68, 0x75, 0x6d,
|
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||||
0x69, 0x64, 0x69, 0x74, 0x79, 0x5f, 0x6f, 0x75, 0x74, 0x64, 0x6f, 0x6f, 0x72, 0x42, 0x12, 0x0a,
|
0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0f, 0x75, 0x70, 0x64, 0x61, 0x74,
|
||||||
0x10, 0x5f, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x5f, 0x69, 0x6e, 0x64, 0x6f, 0x6f,
|
0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x74,
|
||||||
0x72, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x73, 0x70, 0x65, 0x65, 0x64,
|
0x65, 0x6d, 0x70, 0x5f, 0x6f, 0x75, 0x74, 0x64, 0x6f, 0x6f, 0x72, 0x5f, 0x66, 0x42, 0x10, 0x0a,
|
||||||
0x5f, 0x6d, 0x70, 0x68, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x67, 0x75,
|
0x0e, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x69, 0x6e, 0x64, 0x6f, 0x6f, 0x72, 0x5f, 0x66, 0x42,
|
||||||
0x73, 0x74, 0x5f, 0x6d, 0x70, 0x68, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x64,
|
0x13, 0x0a, 0x11, 0x5f, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x5f, 0x6f, 0x75, 0x74,
|
||||||
0x61, 0x69, 0x6c, 0x79, 0x5f, 0x67, 0x75, 0x73, 0x74, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x77, 0x69,
|
0x64, 0x6f, 0x6f, 0x72, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74,
|
||||||
0x6e, 0x64, 0x5f, 0x64, 0x69, 0x72, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f,
|
0x79, 0x5f, 0x69, 0x6e, 0x64, 0x6f, 0x6f, 0x72, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x77, 0x69, 0x6e,
|
||||||
0x64, 0x69, 0x72, 0x5f, 0x61, 0x76, 0x67, 0x5f, 0x31, 0x30, 0x6d, 0x42, 0x05, 0x0a, 0x03, 0x5f,
|
0x64, 0x5f, 0x73, 0x70, 0x65, 0x65, 0x64, 0x5f, 0x6d, 0x70, 0x68, 0x42, 0x10, 0x0a, 0x0e, 0x5f,
|
||||||
0x75, 0x76, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x73, 0x6f, 0x6c, 0x61, 0x72, 0x5f, 0x72, 0x61, 0x64,
|
0x77, 0x69, 0x6e, 0x64, 0x5f, 0x67, 0x75, 0x73, 0x74, 0x5f, 0x6d, 0x70, 0x68, 0x42, 0x11, 0x0a,
|
||||||
0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x68, 0x6f, 0x75, 0x72, 0x6c,
|
0x0f, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x5f, 0x67, 0x75, 0x73, 0x74,
|
||||||
0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x65, 0x76,
|
0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x64, 0x69, 0x72, 0x42, 0x13, 0x0a,
|
||||||
0x65, 0x6e, 0x74, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x10, 0x0a, 0x0e, 0x5f,
|
0x11, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x64, 0x69, 0x72, 0x5f, 0x61, 0x76, 0x67, 0x5f, 0x31,
|
||||||
0x64, 0x61, 0x69, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x11, 0x0a,
|
0x30, 0x6d, 0x42, 0x05, 0x0a, 0x03, 0x5f, 0x75, 0x76, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x73, 0x6f,
|
||||||
0x0f, 0x5f, 0x77, 0x65, 0x65, 0x6b, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e,
|
0x6c, 0x61, 0x72, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x11, 0x0a,
|
||||||
0x42, 0x12, 0x0a, 0x10, 0x5f, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69,
|
0x0f, 0x5f, 0x68, 0x6f, 0x75, 0x72, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e,
|
||||||
0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x79, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x5f,
|
0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f,
|
||||||
0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x74, 0x6f, 0x74, 0x61,
|
0x69, 0x6e, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69,
|
||||||
0x6c, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x62, 0x61,
|
0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x77, 0x65, 0x65, 0x6b, 0x6c, 0x79, 0x5f,
|
||||||
0x72, 0x6f, 0x6d, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x42,
|
0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x6d, 0x6f, 0x6e, 0x74,
|
||||||
0x14, 0x0a, 0x12, 0x5f, 0x62, 0x61, 0x72, 0x6f, 0x6d, 0x5f, 0x61, 0x62, 0x73, 0x6f, 0x6c, 0x75,
|
0x68, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x11, 0x0a, 0x0f, 0x5f,
|
||||||
0x74, 0x65, 0x5f, 0x69, 0x6e, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x64, 0x65, 0x77, 0x5f, 0x70, 0x6f,
|
0x79, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x10,
|
||||||
0x69, 0x6e, 0x74, 0x5f, 0x66, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x63,
|
0x0a, 0x0e, 0x5f, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e,
|
||||||
0x68, 0x69, 0x6c, 0x6c, 0x5f, 0x66, 0x22, 0x7d, 0x0a, 0x12, 0x54, 0x65, 0x6d, 0x70, 0x48, 0x75,
|
0x42, 0x14, 0x0a, 0x12, 0x5f, 0x62, 0x61, 0x72, 0x6f, 0x6d, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74,
|
||||||
0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04,
|
0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x62, 0x61, 0x72, 0x6f, 0x6d,
|
||||||
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
|
0x5f, 0x61, 0x62, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x65, 0x5f, 0x69, 0x6e, 0x42, 0x0e, 0x0a, 0x0c,
|
||||||
0x12, 0x1a, 0x0a, 0x06, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x66, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01,
|
0x5f, 0x64, 0x65, 0x77, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x66, 0x42, 0x0f, 0x0a, 0x0d,
|
||||||
0x48, 0x00, 0x52, 0x05, 0x74, 0x65, 0x6d, 0x70, 0x46, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08,
|
0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x63, 0x68, 0x69, 0x6c, 0x6c, 0x5f, 0x66, 0x22, 0x7d, 0x0a,
|
||||||
0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01,
|
0x12, 0x54, 0x65, 0x6d, 0x70, 0x48, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x53, 0x65, 0x6e,
|
||||||
0x52, 0x08, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x42, 0x09, 0x0a,
|
0x73, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x07, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x66, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x68, 0x75, 0x6d,
|
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x06, 0x74, 0x65, 0x6d, 0x70, 0x5f,
|
||||||
0x69, 0x64, 0x69, 0x74, 0x79, 0x22, 0x55, 0x0a, 0x0d, 0x42, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79,
|
0x66, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x05, 0x74, 0x65, 0x6d, 0x70, 0x46,
|
||||||
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e,
|
0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x18,
|
||||||
0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f,
|
0x03, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01, 0x52, 0x08, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74,
|
||||||
0x6e, 0x65, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02,
|
0x79, 0x88, 0x01, 0x01, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x66, 0x42,
|
||||||
0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x88, 0x01,
|
0x0b, 0x0a, 0x09, 0x5f, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x22, 0x55, 0x0a, 0x0d,
|
||||||
0x01, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x54, 0x5a, 0x52,
|
0x42, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x0a,
|
||||||
0x67, 0x69, 0x74, 0x65, 0x61, 0x2e, 0x6c, 0x69, 0x62, 0x72, 0x65, 0x74, 0x65, 0x63, 0x68, 0x63,
|
0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x6d,
|
0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x06, 0x73,
|
||||||
0x63, 0x67, 0x75, 0x69, 0x72, 0x65, 0x2f, 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x2d, 0x6c,
|
0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x06, 0x73,
|
||||||
0x6f, 0x63, 0x61, 0x6c, 0x2d, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x2f, 0x61, 0x70,
|
0x74, 0x61, 0x74, 0x75, 0x73, 0x88, 0x01, 0x01, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x73, 0x74, 0x61,
|
||||||
0x69, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x77, 0x65, 0x61, 0x74, 0x68,
|
0x74, 0x75, 0x73, 0x42, 0x54, 0x5a, 0x52, 0x67, 0x69, 0x74, 0x65, 0x61, 0x2e, 0x6c, 0x69, 0x62,
|
||||||
0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x72, 0x65, 0x74, 0x65, 0x63, 0x68, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x74, 0x69, 0x6e, 0x67,
|
||||||
|
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x6d, 0x63, 0x67, 0x75, 0x69, 0x72, 0x65, 0x2f, 0x61, 0x6d,
|
||||||
|
0x62, 0x69, 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x2d, 0x65, 0x78, 0x70, 0x6f,
|
||||||
|
0x72, 0x74, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
|
||||||
|
0x31, 0x2f, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
|
0x33,
|
||||||
})
|
})
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -726,11 +739,12 @@ var file_weather_weather_proto_depIdxs = []int32{
|
|||||||
3, // 2: ambient.weather.GetWeatherResponse.weather_updates:type_name -> ambient.weather.WeatherUpdate
|
3, // 2: ambient.weather.GetWeatherResponse.weather_updates:type_name -> ambient.weather.WeatherUpdate
|
||||||
5, // 3: ambient.weather.WeatherUpdate.batteries:type_name -> ambient.weather.BatteryStatus
|
5, // 3: ambient.weather.WeatherUpdate.batteries:type_name -> ambient.weather.BatteryStatus
|
||||||
4, // 4: ambient.weather.WeatherUpdate.temp_humidity_sensors:type_name -> ambient.weather.TempHumiditySensor
|
4, // 4: ambient.weather.WeatherUpdate.temp_humidity_sensors:type_name -> ambient.weather.TempHumiditySensor
|
||||||
5, // [5:5] is the sub-list for method output_type
|
6, // 5: ambient.weather.WeatherUpdate.update_timestamp:type_name -> google.protobuf.Timestamp
|
||||||
5, // [5:5] is the sub-list for method input_type
|
6, // [6:6] is the sub-list for method output_type
|
||||||
5, // [5:5] is the sub-list for extension type_name
|
6, // [6:6] is the sub-list for method input_type
|
||||||
5, // [5:5] is the sub-list for extension extendee
|
6, // [6:6] is the sub-list for extension type_name
|
||||||
0, // [0:5] is the sub-list for field type_name
|
6, // [6:6] is the sub-list for extension extendee
|
||||||
|
0, // [0:6] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_weather_weather_proto_init() }
|
func init() { file_weather_weather_proto_init() }
|
||||||
|
89
contrib/wu_sample.json
Normal file
89
contrib/wu_sample.json
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
{
|
||||||
|
"PASSKEY": [
|
||||||
|
"DE:AD:BE:EF:BE:EF"
|
||||||
|
],
|
||||||
|
"baromabsin": [
|
||||||
|
"29.025"
|
||||||
|
],
|
||||||
|
"baromrelin": [
|
||||||
|
"30.005"
|
||||||
|
],
|
||||||
|
"batt1": [
|
||||||
|
"1"
|
||||||
|
],
|
||||||
|
"battin": [
|
||||||
|
"1"
|
||||||
|
],
|
||||||
|
"battout": [
|
||||||
|
"1"
|
||||||
|
],
|
||||||
|
"battrain": [
|
||||||
|
"1"
|
||||||
|
],
|
||||||
|
"dailyrainin": [
|
||||||
|
"0.000"
|
||||||
|
],
|
||||||
|
"dateutc": [
|
||||||
|
"2025-03-23 14:07:59"
|
||||||
|
],
|
||||||
|
"eventrainin": [
|
||||||
|
"0.000"
|
||||||
|
],
|
||||||
|
"hourlyrainin": [
|
||||||
|
"0.000"
|
||||||
|
],
|
||||||
|
"humidity": [
|
||||||
|
"55"
|
||||||
|
],
|
||||||
|
"humidity1": [
|
||||||
|
"53"
|
||||||
|
],
|
||||||
|
"humidityin": [
|
||||||
|
"36"
|
||||||
|
],
|
||||||
|
"maxdailygust": [
|
||||||
|
"20.36"
|
||||||
|
],
|
||||||
|
"monthlyrainin": [
|
||||||
|
"1.969"
|
||||||
|
],
|
||||||
|
"solarradiation": [
|
||||||
|
"142.15"
|
||||||
|
],
|
||||||
|
"stationtype": [
|
||||||
|
"WeatherHub_V1.0.2"
|
||||||
|
],
|
||||||
|
"temp1f": [
|
||||||
|
"-2.74"
|
||||||
|
],
|
||||||
|
"tempf": [
|
||||||
|
"33.98"
|
||||||
|
],
|
||||||
|
"tempinf": [
|
||||||
|
"70.52"
|
||||||
|
],
|
||||||
|
"totalrainin": [
|
||||||
|
"2.421"
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
"1"
|
||||||
|
],
|
||||||
|
"weeklyrainin": [
|
||||||
|
"0.000"
|
||||||
|
],
|
||||||
|
"winddir": [
|
||||||
|
"117"
|
||||||
|
],
|
||||||
|
"winddir_avg10m": [
|
||||||
|
"127"
|
||||||
|
],
|
||||||
|
"windgustmph": [
|
||||||
|
"17.22"
|
||||||
|
],
|
||||||
|
"windspeedmph": [
|
||||||
|
"10.29"
|
||||||
|
],
|
||||||
|
"yearlyrainin": [
|
||||||
|
"2.421"
|
||||||
|
]
|
||||||
|
}
|
9
contrib/wu_test_sample.sh
Executable file
9
contrib/wu_test_sample.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!env sh
|
||||||
|
SCRIPT_DIR=$( dirname $0 )
|
||||||
|
JSON_FILE="${SCRIPT_DIR}/wu_sample.json"
|
||||||
|
BASE_URL="http://127.0.0.1:8080/data/report"
|
||||||
|
|
||||||
|
# Convert JSON to query parameters
|
||||||
|
QUERY_STRING=$(jq -r 'to_entries | map("\(.key)=\(.value[0] | @uri)") | join("&")' "$JSON_FILE")
|
||||||
|
|
||||||
|
curl -G --data "$QUERY_STRING" "$BASE_URL"
|
@ -15,13 +15,13 @@ type: application
|
|||||||
# This is the chart version. This version number should be incremented each time you make changes
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
# to the chart and its templates, including the app version.
|
# to the chart and its templates, including the app version.
|
||||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
version: 0.1.2
|
version: 0.1.4
|
||||||
|
|
||||||
# This is the version number of the application being deployed. This version number should be
|
# This is the version number of the application being deployed. This version number should be
|
||||||
# incremented each time you make changes to the application. Versions are not expected to
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
# It is recommended to use it with quotes.
|
# It is recommended to use it with quotes.
|
||||||
appVersion: "v0.10.2"
|
appVersion: "v0.11.2"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: hull
|
- name: hull
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
package grpc
|
package grpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"slices"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
|
||||||
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
||||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/util"
|
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/util"
|
||||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Converts a slice of weather.WeatherUpdate to proto structs
|
||||||
func UpdatesToPbUpdates(u []*weather.WeatherUpdate) []*pb.WeatherUpdate {
|
func UpdatesToPbUpdates(u []*weather.WeatherUpdate) []*pb.WeatherUpdate {
|
||||||
updates := make([]*pb.WeatherUpdate, len(u))
|
updates := make([]*pb.WeatherUpdate, len(u))
|
||||||
for i, update := range u {
|
for i, update := range u {
|
||||||
@ -14,7 +20,16 @@ func UpdatesToPbUpdates(u []*weather.WeatherUpdate) []*pb.WeatherUpdate {
|
|||||||
return updates
|
return updates
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Maps a weather.WeatherUpdate to the proto version.
|
||||||
|
//
|
||||||
|
// This should be auto-generated code, but as the proto should be
|
||||||
|
// stable, it is probably not worth the effort.
|
||||||
func UpdateToPbUpdate(u *weather.WeatherUpdate) *pb.WeatherUpdate {
|
func UpdateToPbUpdate(u *weather.WeatherUpdate) *pb.WeatherUpdate {
|
||||||
|
if u.DateUTC == nil {
|
||||||
|
now := time.Now()
|
||||||
|
u.DateUTC = &now
|
||||||
|
}
|
||||||
|
|
||||||
return &pb.WeatherUpdate{
|
return &pb.WeatherUpdate{
|
||||||
StationName: u.StationConfig.Name,
|
StationName: u.StationConfig.Name,
|
||||||
StationType: util.DerefStr(u.StationType),
|
StationType: util.DerefStr(u.StationType),
|
||||||
@ -43,28 +58,33 @@ func UpdateToPbUpdate(u *weather.WeatherUpdate) *pb.WeatherUpdate {
|
|||||||
DewPointF: u.DewPointF,
|
DewPointF: u.DewPointF,
|
||||||
WindChillF: u.WindChillF,
|
WindChillF: u.WindChillF,
|
||||||
TempHumiditySensors: thSensorsToPbSensors(u.TempHumiditySensors),
|
TempHumiditySensors: thSensorsToPbSensors(u.TempHumiditySensors),
|
||||||
|
UpdateTimestamp: timestamppb.New(*u.DateUTC),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func batteriesToPbBatteries(batteries []weather.BatteryStatus) []*pb.BatteryStatus {
|
func batteriesToPbBatteries(batteries []weather.BatteryStatus) []*pb.BatteryStatus {
|
||||||
pbBatteries := make([]*pb.BatteryStatus, len(batteries))
|
pbBatteries := make([]*pb.BatteryStatus, 0, len(batteries))
|
||||||
for i, b := range batteries {
|
for _, b := range batteries {
|
||||||
pbBatteries[i] = &pb.BatteryStatus{
|
if b.Status != nil {
|
||||||
Component: b.Component,
|
pbBatteries = append(pbBatteries, &pb.BatteryStatus{
|
||||||
Status: util.Int32ptr(b.Status),
|
Component: b.Component,
|
||||||
|
Status: util.Int32ptr(b.Status),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pbBatteries
|
return slices.Clip(pbBatteries)
|
||||||
}
|
}
|
||||||
|
|
||||||
func thSensorsToPbSensors(sensors []*weather.TempHumiditySensor) []*pb.TempHumiditySensor {
|
func thSensorsToPbSensors(sensors []*weather.TempHumiditySensor) []*pb.TempHumiditySensor {
|
||||||
pbSensors := make([]*pb.TempHumiditySensor, len(sensors))
|
pbSensors := make([]*pb.TempHumiditySensor, 0, len(sensors))
|
||||||
for i, s := range sensors {
|
for _, s := range sensors {
|
||||||
pbSensors[i] = &pb.TempHumiditySensor{
|
if s.TempF != nil || s.Humidity != nil {
|
||||||
Name: s.Name,
|
pbSensors = append(pbSensors, &pb.TempHumiditySensor{
|
||||||
TempF: s.TempF,
|
Name: s.Name,
|
||||||
Humidity: util.Int32ptr(s.Humidity),
|
TempF: s.TempF,
|
||||||
|
Humidity: util.Int32ptr(s.Humidity),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pbSensors
|
return slices.Clip(pbSensors)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
"k8s.io/utils/ptr"
|
"k8s.io/utils/ptr"
|
||||||
|
|
||||||
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
||||||
@ -12,8 +13,10 @@ import (
|
|||||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var now = time.Now()
|
||||||
|
|
||||||
var mockUpdate = &weather.WeatherUpdate{
|
var mockUpdate = &weather.WeatherUpdate{
|
||||||
DateUTC: &time.Time{},
|
DateUTC: &now,
|
||||||
StationConfig: &config.WeatherStation{
|
StationConfig: &config.WeatherStation{
|
||||||
Name: "50W",
|
Name: "50W",
|
||||||
Equipment: "WS-5000",
|
Equipment: "WS-5000",
|
||||||
@ -100,6 +103,7 @@ func TestUpdateToPbUpdate(t *testing.T) {
|
|||||||
Humidity: nil,
|
Humidity: nil,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
UpdateTimestamp: timestamppb.New(now),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,28 @@ import (
|
|||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
|
||||||
|
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient/config"
|
||||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/util"
|
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/util"
|
||||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (w *WeatherRecorder) Set(ctx context.Context, u *weather.WeatherUpdate) error {
|
func (w *WeatherRecorder) Set(ctx context.Context, u *weather.WeatherUpdate) error {
|
||||||
|
if u.StationConfig == nil {
|
||||||
|
u.StationConfig = &config.WeatherStation{
|
||||||
|
Name: "unregistered",
|
||||||
|
Equipment: "unknown",
|
||||||
|
ProxyToAWN: false,
|
||||||
|
ProxyToWunderground: false,
|
||||||
|
KeepMetrics: []string{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx, span := w.tracer.Start(ctx, "setRecorderUpdate", trace.WithAttributes(
|
ctx, span := w.tracer.Start(ctx, "setRecorderUpdate", trace.WithAttributes(
|
||||||
attribute.String("stationName", u.StationConfig.Name),
|
attribute.String("stationName", u.StationConfig.Name),
|
||||||
attribute.String("stationType", util.DerefStr(u.StationType)),
|
attribute.String("stationType", util.DerefStr(u.StationType)),
|
||||||
attribute.String("stationEquipment", u.StationConfig.Equipment),
|
attribute.String("stationEquipment", u.StationConfig.Equipment),
|
||||||
))
|
))
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
return w.recorder.Set(ctx, u)
|
return w.recorder.Set(ctx, u)
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,9 @@ func (r *RedisRecorder) get(ctx context.Context, req *pb.GetWeatherRequest) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
span.SetAttributes(attribute.Int("limit", limit))
|
span.SetAttributes(attribute.Int("limit", limit))
|
||||||
|
r.log.Debug().Int("limit", limit).Msg("getting updates from redis")
|
||||||
|
|
||||||
datas, err := r.redis.LRange(ctx, r.Key(), 0, int64(limit)).Result()
|
datas, err := r.redis.LRange(ctx, r.Key(), 0, int64(limit)-1).Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
span.SetStatus(codes.Error, err.Error())
|
span.SetStatus(codes.Error, err.Error())
|
||||||
@ -48,6 +49,7 @@ func (r *RedisRecorder) get(ctx context.Context, req *pb.GetWeatherRequest) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
span.AddEvent("redis queried")
|
span.AddEvent("redis queried")
|
||||||
|
r.log.Debug().Int("results", len(datas)).Msg("redis queried")
|
||||||
|
|
||||||
updates, err := jsonDatasToUpdates(datas)
|
updates, err := jsonDatasToUpdates(datas)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -75,7 +77,7 @@ func (r *RedisRecorder) get(ctx context.Context, req *pb.GetWeatherRequest) (
|
|||||||
Int("updatesFiltered", len(updates)-len(filtered)).
|
Int("updatesFiltered", len(updates)-len(filtered)).
|
||||||
Msg("updates retrieved from redis")
|
Msg("updates retrieved from redis")
|
||||||
|
|
||||||
return updates, err
|
return filtered, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func jsonDatasToUpdates(datas []string) ([]*weather.WeatherUpdate, error) {
|
func jsonDatasToUpdates(datas []string) ([]*weather.WeatherUpdate, error) {
|
||||||
@ -87,7 +89,7 @@ func jsonDatasToUpdates(datas []string) ([]*weather.WeatherUpdate, error) {
|
|||||||
err := json.Unmarshal([]byte(data), update)
|
err := json.Unmarshal([]byte(data), update)
|
||||||
errs = errors.Join(errs, err)
|
errs = errors.Join(errs, err)
|
||||||
|
|
||||||
if err != nil {
|
if err == nil {
|
||||||
updates = append(updates, update)
|
updates = append(updates, update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/redis/go-redis/v9"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/codes"
|
"go.opentelemetry.io/otel/codes"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
@ -20,7 +21,7 @@ func (r *RedisRecorder) Set(ctx context.Context, u *weather.WeatherUpdate) error
|
|||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
r.Lock()
|
r.Lock()
|
||||||
defer r.RUnlock()
|
defer r.Unlock()
|
||||||
|
|
||||||
// First ensure we can prepare our payload
|
// First ensure we can prepare our payload
|
||||||
data, err := json.Marshal(u)
|
data, err := json.Marshal(u)
|
||||||
@ -42,11 +43,14 @@ func (r *RedisRecorder) set(ctx context.Context, data []byte) error {
|
|||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
// Atomic, push and trim
|
// Atomic, push and trim
|
||||||
tx := r.redis.TxPipeline()
|
var count *redis.IntCmd
|
||||||
tx.LPush(ctx, r.Key(), data)
|
rErr, err := r.redis.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
|
||||||
tx.LTrim(ctx, r.Key(), 0, int64(r.keep)-1)
|
pipe.LPush(ctx, r.Key(), data)
|
||||||
|
pipe.LTrim(ctx, r.Key(), 0, int64(r.keep)-1)
|
||||||
if rErr, err := tx.Exec(ctx); err != nil {
|
count = pipe.LLen(ctx, r.Key())
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
for _, cmd := range rErr {
|
for _, cmd := range rErr {
|
||||||
span.RecordError(cmd.Err())
|
span.RecordError(cmd.Err())
|
||||||
}
|
}
|
||||||
@ -55,7 +59,16 @@ func (r *RedisRecorder) set(ctx context.Context, data []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
span.SetAttributes(attribute.Int("updateCount", r.count(ctx)))
|
// Get new update count
|
||||||
|
|
||||||
|
r.log.Debug().
|
||||||
|
Int("updateBytes", len(data)).
|
||||||
|
Int64("updateCount", count.Val()).
|
||||||
|
Str("redis", r.redis.String()).
|
||||||
|
Str("key", r.Key()).
|
||||||
|
Msg("pushed update to redis")
|
||||||
|
|
||||||
|
span.SetAttributes(attribute.Int64("updateCount", count.Val()))
|
||||||
span.SetStatus(codes.Ok, "")
|
span.SetStatus(codes.Ok, "")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ message WeatherUpdate {
|
|||||||
optional double dew_point_f = 25;
|
optional double dew_point_f = 25;
|
||||||
optional double wind_chill_f = 26;
|
optional double wind_chill_f = 26;
|
||||||
repeated TempHumiditySensor temp_humidity_sensors = 27;
|
repeated TempHumiditySensor temp_humidity_sensors = 27;
|
||||||
|
google.protobuf.Timestamp update_timestamp = 28;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Represents a temperature and humidity sensor
|
// Represents a temperature and humidity sensor
|
||||||
|
Reference in New Issue
Block a user