func (f *ExchangeFactory) Build() (ExchangeOrganizer, error) {
	if f.creator == nil {
		return nil, errors.New("no channel creator was provided")
	}
	if f.client == nil {
		return nil, errors.New("no openfaas client was provided")
	}
	if f.exchange == nil {
		return nil, errors.New("no exchange configured")
	}
	channel, err := f.creator.Channel()
	if err != nil {
		return nil, err
	}
	topologyErr := declareTopology(channel, f.exchange)
	if topologyErr != nil {
		return nil, topologyErr
	}
	return NewExchange(channel, f.client, f.exchange), nil
}
Build uses the set values and builds a new exchange from them
package rabbitmq
import (
	"errors"
	"fmt"
	"log"
	"github.com/Templum/rabbitmq-connector/pkg/types"
	"github.com/streadway/amqp"
)
type Factory interface {
	WithInvoker(client types.Invoker) Factory
	WithChanCreator(creator ChannelCreator) Factory
	WithExchange(ex *types.Exchange) Factory
	Build() (ExchangeOrganizer, error)
}
func NewFactory() Factory {
	return &ExchangeFactory{}
}
type ExchangeFactory struct {
	creator  ChannelCreator
	client   types.Invoker
	exchange *types.Exchange
}
func (f *ExchangeFactory) WithChanCreator(creator ChannelCreator) Factory {
	f.creator = creator
	return f
}
func (f *ExchangeFactory) WithInvoker(client types.Invoker) Factory {
	f.client = client
	return f
}
func (f *ExchangeFactory) WithExchange(ex *types.Exchange) Factory {
	log.Printf("Factory is configured for exchange %s", ex.Name)
	ex.EnsureCorrectType()
	f.exchange = ex
	return f
}