package messaging

import (
	"github.com/mitchellh/mapstructure"
	mb "github.com/tech/sendico/pkg/messaging/broker"
	"github.com/tech/sendico/pkg/messaging/internal/natsb"
	nc "github.com/tech/sendico/pkg/messaging/internal/natsb/config"
	"github.com/tech/sendico/pkg/mlogger"
	"github.com/tech/sendico/pkg/model"
)

func NewNATSBroker(logger mlogger.Logger, config model.SettingsT) (mb.Broker, error) {
	var conf nc.Settings
	if err := mapstructure.Decode(config, &conf); err != nil {
		return nil, err
	}
	return natsb.NewNatsBroker(logger, &conf)
}
