From fe87cd50c7193a590ff9e5c4a09fdd124d97388f Mon Sep 17 00:00:00 2001 From: Jordan Hotmann Date: Wed, 6 Dec 2023 22:30:51 -0700 Subject: [PATCH] Request in goroutine --- internal/homeassistant/subscriber.go | 3 +-- internal/nats/client.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/homeassistant/subscriber.go b/internal/homeassistant/subscriber.go index bdddd4f..4fa4a13 100644 --- a/internal/homeassistant/subscriber.go +++ b/internal/homeassistant/subscriber.go @@ -156,8 +156,7 @@ func handleMessages() { data, _ := json.Marshal(message.Event.Data) nats.Publish(fmt.Sprintf("homeassistant.zwave-scene.%s", message.Event.Data.DeviceId), data) case timerFinishedEventId: - // nats.PublishString(fmt.Sprintf("homeassistant.%s.finished", message.Event.Data.EntityId), "finished") - nats.PublishRequest(fmt.Sprintf("homeassistant.%s.finished", message.Event.Data.EntityId), []byte("finished"), 500*time.Millisecond, 3) + go nats.PublishRequest(fmt.Sprintf("homeassistant.%s.finished", message.Event.Data.EntityId), []byte("finished"), 500*time.Millisecond, 3) } } } diff --git a/internal/nats/client.go b/internal/nats/client.go index 8b5889f..db341f8 100644 --- a/internal/nats/client.go +++ b/internal/nats/client.go @@ -94,7 +94,7 @@ func PublishRequest(subject string, message []byte, timeout time.Duration, retri resp, err := client.Conn.Request(subject, message, timeout) if err == nil { - logger.Debug("Request response received", "response", string(resp.Data)) + logger.Debug("Request response received", "response", string(resp.Data), "attempts", attempts) return } }