set broker address on Init

This commit is contained in:
Asim Aslam 2018-08-18 17:28:58 +01:00
parent a0d3917832
commit 9d3cb65daa

View File

@ -276,7 +276,6 @@ func (h *httpBroker) Address() string {
}
func (h *httpBroker) Connect() error {
h.RLock()
if h.running {
h.RUnlock()
@ -397,6 +396,10 @@ func (h *httpBroker) Init(opts ...Option) error {
o(&h.opts)
}
if len(h.opts.Addrs) > 0 && len(h.opts.Addrs[0]) > 0 {
h.address = h.opts.Addrs[0]
}
if len(h.id) == 0 {
h.id = "broker-" + uuid.NewUUID().String()
}