From 6f3cbf54fb89654ea94cdb7510474ec6aeef1c6a Mon Sep 17 00:00:00 2001
From: Ruben Vermeersch <ruben@rocketeer.be>
Date: Tue, 7 May 2024 16:26:34 +0200
Subject: [PATCH] Allow setting autoDelete on queues

---
 manager.go | 10 +++++-----
 model.go   | 11 ++++++-----
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/manager.go b/manager.go
index bd064f7..375f7b4 100644
--- a/manager.go
+++ b/manager.go
@@ -210,11 +210,11 @@ func (manager *mqttManager) CreateQueue(config QueueConfig) error {
 
 	// We declare the queue via the channel.
 	_, err := manager.channel.QueueDeclare(
-		config.Name,      // name
-		config.Durable,   // durable
-		false,            // delete when unused
-		config.Exclusive, // exclusive
-		false,            // no-wait
+		config.Name,       // name
+		config.Durable,    // durable
+		config.AutoDelete, // delete when unused
+		config.Exclusive,  // exclusive
+		false,             // no-wait
 		config.Args,
 	)
 
diff --git a/model.go b/model.go
index 09c5394..93e68e1 100644
--- a/model.go
+++ b/model.go
@@ -42,11 +42,12 @@ type ExchangeConfig struct {
 }
 
 type QueueConfig struct {
-	Name      string                 `yaml:"name"`
-	Durable   bool                   `yaml:"durable"`
-	Exclusive bool                   `yaml:"exclusive"`
-	Args      map[string]interface{} `yaml:"args"`
-	Bindings  []BindingConfig        `yaml:"bindings"`
+	Name       string                 `yaml:"name"`
+	Durable    bool                   `yaml:"durable"`
+	Exclusive  bool                   `yaml:"exclusive"`
+	AutoDelete bool                   `yaml:"autoDelete"`
+	Args       map[string]interface{} `yaml:"args"`
+	Bindings   []BindingConfig        `yaml:"bindings"`
 }
 
 type BindingConfig struct {