fix nil ref

main
Niko Abeler 4 months ago
parent 21de378fbc
commit 599c4861a6
  1. 8
      gatherer/main.go
  2. 1
      gatherer/piper.go

@ -16,7 +16,7 @@ func failOnError(err error, msg string) {
func main() {
amqpConn := AMQPConnection{}
amqpConn := new(AMQPConnection)
amqpConn.Init()
err := amqpConn.Connect()
defer amqpConn.Close()
@ -30,7 +30,7 @@ func main() {
fmt.Println("InfluxDB token:")
fmt.Println(strings.TrimSpace(string(influx_token)))
influx := InfluxWriter{}
influx := new(InfluxWriter)
influx.Init(
os.Getenv("INFLUX_URL"),
strings.TrimSpace(string(influx_token)),
@ -53,10 +53,10 @@ func main() {
var forever chan struct{}
shellPipe := new(Piper)
shellPipe.Start(&influx, &amqpConn, "shelly", "shellies.#", ShellyConverter)
shellPipe.Start(influx, amqpConn, "shelly", "shellies.#", ShellyConverter)
tasmotaPipe := new(Piper)
tasmotaPipe.Start(&influx, &amqpConn, "tasmota", "tele.#.SENSOR", TasmotaConverter)
tasmotaPipe.Start(influx, amqpConn, "tasmota", "tele.#.SENSOR", TasmotaConverter)
log.Printf(" [*] Waiting for logs. To exit press CTRL+C")
<-forever

@ -20,6 +20,7 @@ func (p *Piper) Start(
// Create a new client using an InfluxDB server base URL and an authentication token
p.influx = writer
p.delivery, _ = amqp.ConnectToQueue(queue_name, routing_key)
p.conversion = conversion
notify := amqp.NotifyError()
go func() {

Loading…
Cancel
Save