fix initialisation
This commit is contained in:
parent
e6d63d9ff0
commit
8948465b0c
@ -85,15 +85,20 @@ func (n *NatsBroker) Subscribe(topic string, function func(*Message)) (Subscribe
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewNatsBroker(addrs []string, opts ...Options) Broker {
|
func NewNatsBroker(addrs []string, opts ...Options) Broker {
|
||||||
if len(addrs) == 0 {
|
var cAddrs []string
|
||||||
addrs = []string{nats.DefaultURL}
|
for _, addr := range addrs {
|
||||||
|
if len(addr) == 0 {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
for i, addr := range addrs {
|
|
||||||
if !strings.HasPrefix(addr, "nats://") {
|
if !strings.HasPrefix(addr, "nats://") {
|
||||||
addrs[i] = "nats://" + addr
|
addr = "nats://" + addr
|
||||||
}
|
}
|
||||||
|
cAddrs = append(cAddrs, addr)
|
||||||
|
}
|
||||||
|
if len(cAddrs) == 0 {
|
||||||
|
cAddrs = []string{nats.DefaultURL}
|
||||||
}
|
}
|
||||||
return &NatsBroker{
|
return &NatsBroker{
|
||||||
addrs: addrs,
|
addrs: cAddrs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user