Last active
July 11, 2024 11:26
-
-
Save BK1031/7c56ce7440663b11ecf463f6a480fb97 to your computer and use it in GitHub Desktop.
racecar_analytics create rows in subscription handlers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func SubscribeECU() { | |
Client.Subscribe("ingest/ecu", 0, func(client mqtt.Client, msg mqtt.Message) { | |
ecu := ECUFromBytes(msg.Payload()) | |
// ------ add this ------ | |
ecu, err := CreateECU(ecu) | |
if err != nil { | |
fmt.Printf("failed to create ecu: %v", err) | |
} | |
// ---------------------- | |
fmt.Printf("[MQ] Received ecu message: %v\n", ecu) | |
}) | |
} | |
func SubscribeBattery() { | |
Client.Subscribe("ingest/battery", 0, func(client mqtt.Client, msg mqtt.Message) { | |
battery := BatteryFromBytes(msg.Payload()) | |
// ------ add this ------ | |
battery, err := CreateBattery(battery) | |
if err != nil { | |
fmt.Printf("failed to create battery: %v", err) | |
} | |
// ---------------------- | |
fmt.Printf("[MQ] Received battery message: %v\n", battery) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment