aboutsummaryrefslogtreecommitdiff
path: root/catbus
diff options
context:
space:
mode:
authorEthel Morgan <eth@ethulhu.co.uk>2020-06-22 21:34:30 +0100
committerEthel Morgan <eth@ethulhu.co.uk>2020-06-22 21:34:30 +0100
commitb80f8b26b1a7d3d1974c77e92515ba8a650bfe45 (patch)
tree587876dc9d96a56615cb4b3bb0510538aa452aae /catbus
parentb9f13df51979ff38e4a9578f982cc608e3bb2c0d (diff)
don't rebroadcast deleted topics
Diffstat (limited to '')
-rw-r--r--catbus/catbus.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/catbus/catbus.go b/catbus/catbus.go
index 9325d8e..a76e644 100644
--- a/catbus/catbus.go
+++ b/catbus/catbus.go
@@ -127,6 +127,12 @@ func (c *Client) rebroadcastLater(topic string, retention Retention, payload []b
if timer := c.rebroadcastByTopic[topic]; timer != nil {
_ = timer.Stop()
}
+
+ if len(payload) == 0 {
+ // No payload => remove => don't rebroadcast.
+ return
+ }
+
c.rebroadcastByTopic[topic] = time.AfterFunc(c.rebroadcastDuration(), func() {
_ = c.Publish(topic, retention, payload)
})