func (b *Broker) Close() {
	if b.lis != nil {
		err := b.lis.Close()
		if err != nil {
			b.log.Info("failed to close listener", log.Error(err))
		}
	}
	if b.ses != nil {
		err := b.ses.Close()
		if err != nil {
			b.log.Info("failed to close listener", log.Error(err))
		}
	}
}
Close closes broker
package broker
import (
	"github.com/baetyl/baetyl-go/v2/errors"
	"github.com/baetyl/baetyl-go/v2/log"
	"github.com/baetyl/baetyl-broker/v2/listener"
	"github.com/baetyl/baetyl-broker/v2/session"
)
type Config struct {
	Listeners []listener.Listener `yaml:"listeners" json:"listeners"`
	Session   session.Config      `yaml:",inline" json:",inline"`
}
type Broker struct {
	cfg Config
	ses *session.Manager
	lis *listener.Manager
	log *log.Logger
}
func NewBroker(cfg Config) (*Broker, error) {
	var err error
	b := &Broker{
		cfg: cfg,
		log: log.With(log.Any("main", "broker")),
	}
	b.ses, err = session.NewManager(cfg.Session)
	if err != nil {
		return nil, errors.Trace(err)
	}
	b.lis, err = listener.NewManager(cfg.Listeners, b.ses)
	if err != nil {
		b.Close()
		return nil, errors.Trace(err)
	}
	return b, nil
}