func (c *Connector) Shutdown() {
	log.Println("Shutdown RabbitMQ <=> OpenFaaS Connector")
	for _, ex := range c.exchanges {
		ex.Stop()
	}
	c.conManager.Disconnect()
}
Shutdown is usually called during graceful shutdown. It stops all exchanges and finally closes the connection
to RabbitMQ
package connector
import (
	"log"
	"github.com/Templum/rabbitmq-connector/pkg/config"
	"github.com/Templum/rabbitmq-connector/pkg/rabbitmq"
	"github.com/Templum/rabbitmq-connector/pkg/types"
	"github.com/streadway/amqp"
)
type RabbitToOpenFaaS interface {
	Run() error
	Shutdown()
}
func New(manager rabbitmq.Manager, factory rabbitmq.Factory, invoker types.Invoker, conf *config.Controller) RabbitToOpenFaaS {
	return &Connector{
		client: invoker,
		factory:    factory,
		conManager: manager,
		conf:       conf,
	}
}
type Connector struct {
	client types.Invoker
	factory    rabbitmq.Factory
	conManager rabbitmq.Manager
	conf       *config.Controller
	exchanges  []rabbitmq.ExchangeOrganizer
}
func (c *Connector) Run() error {
	log.Println("Started RabbitMQ <=> OpenFaaS Connector")
	log.Printf("Will now establish connection to %s", c.conf.RabbitSanitizedURL)
	failureChan, conErr := c.conManager.Connect(c.conf.RabbitConnectionURL)
	if conErr != nil {
		return conErr
	}
	go c.HandleConnectionError(failureChan)
	genErr := c.generateExchangesFrom(c.conf.Topology)
	if genErr != nil {
		return genErr
	}
	for _, ex := range c.exchanges {
		err := ex.Start()
		if err != nil {
			return err
		}
	}
	return nil
}
func (c *Connector) HandleConnectionError(ch <-chan *amqp.Error) {
	err := <-ch
	log.Printf("Rabbit MQ Connection failed with %s Code: %d [Server=%t Recover=%t]", err.Reason, err.Code, err.Server, err.Recover)
	if err.Recover {
		for _, ex := range c.exchanges {
			ex.Stop()
		}
		c.exchanges = nil
		err := c.Run()
		if err != nil {
			log.Panicf("Received critical error: %s during restart, shutting down", err)
		}
	} else {
		log.Panicf("Received critical error: %s, shutting down", err)
	}
}