func NewBroker(config BrokerConfig) (Broker, error) {
	broker := &broker{}
	brokerURL := fmt.Sprintf("nats://%s:%s", config.Host, NATSPort)
	for {
		client, err := nats.Connect(brokerURL,
			nats.Timeout(config.ConnTimeout),
			nats.Name(clientName))
		if client != nil && err == nil {
			broker.client = client
			break
		}
		if client != nil {
			client.Close()
		}
		log.Println("Wait for brokers to come up.. ", brokerURL)
		time.Sleep(1 * time.Second)
	}
	return broker, nil
}
NewBroker loops until we are able to connect to the NATS server
package nats
import (
	"fmt"
	"log"
	"sync"
	"time"
	nats "github.com/nats-io/nats.go"
	"github.com/openfaas-incubator/connector-sdk/types"
)
const queueGroup = "openfaas_nats_worker_group"
const clientName = "openfaas_connector"
type BrokerConfig struct {
	Host string
	ConnTimeout time.Duration
}
type Broker interface {
	Subscribe(types.Controller, []string) error
}
type broker struct {
	client *nats.Conn
}
const NATSPort = "4222"