This commit is contained in:
Niko Abeler 2023-02-16 21:01:30 +01:00
parent 29c5b37799
commit da634efa8c
3 changed files with 4 additions and 3 deletions

View File

@ -99,6 +99,7 @@ func (amqpConn *AMQPConnection) ConnectToQueue(name string, routing_key string)
func (amqpConn *AMQPConnection) NotifyError() <-chan bool { func (amqpConn *AMQPConnection) NotifyError() <-chan bool {
notify := make(chan bool) notify := make(chan bool)
amqpConn.observers = append(amqpConn.observers, notify) amqpConn.observers = append(amqpConn.observers, notify)
log.Println("Added observer")
return notify return notify
} }

View File

@ -53,11 +53,11 @@ func main() {
var forever chan struct{} var forever chan struct{}
shellPipe := Piper{} shellPipe := Piper{}
shellPipe.Init(&influx, amqpConn, "shelly", "shellies.#") shellPipe.Init(&influx, &amqpConn, "shelly", "shellies.#")
go shellPipe.RunPipe(ShellyConverter) go shellPipe.RunPipe(ShellyConverter)
tasmotaPipe := Piper{} tasmotaPipe := Piper{}
tasmotaPipe.Init(&influx, amqpConn, "tasmota", "tele.#.SENSOR") tasmotaPipe.Init(&influx, &amqpConn, "tasmota", "tele.#.SENSOR")
go tasmotaPipe.RunPipe(TasmotaConverter) go tasmotaPipe.RunPipe(TasmotaConverter)
log.Printf(" [*] Waiting for logs. To exit press CTRL+C") log.Printf(" [*] Waiting for logs. To exit press CTRL+C")

View File

@ -10,7 +10,7 @@ type Piper struct {
delivery <-chan amqp.Delivery delivery <-chan amqp.Delivery
} }
func (p *Piper) Init(writer *InfluxWriter, amqp AMQPConnection, queue_name string, routing_key string) { func (p *Piper) Init(writer *InfluxWriter, amqp *AMQPConnection, queue_name string, routing_key string) {
// Create a new client using an InfluxDB server base URL and an authentication token // Create a new client using an InfluxDB server base URL and an authentication token
p.influx = writer p.influx = writer
p.delivery, _ = amqp.ConnectToQueue(queue_name, routing_key) p.delivery, _ = amqp.ConnectToQueue(queue_name, routing_key)