strip broker address

This commit is contained in:
Asim Aslam 2019-07-07 12:33:47 +01:00
parent 5f664faeba
commit c1097a4509
4 changed files with 10 additions and 4 deletions

View File

@ -3,11 +3,10 @@ package broker
// Broker is an interface used for asynchronous messaging.
type Broker interface {
Init(...Option) error
Options() Options
Address() string
Connect() error
Disconnect() error
Init(...Option) error
Publish(string, *Message, ...PublishOption) error
Subscribe(string, Handler, ...SubscribeOption) (Subscriber, error)
String() string

View File

@ -403,6 +403,7 @@ func (h *httpBroker) Connect() error {
go func() {
h.run(l)
h.Lock()
h.opts.Addrs = []string{addr}
h.address = addr
h.Unlock()
}()

View File

@ -714,7 +714,10 @@ func (g *grpcServer) Start() error {
return err
}
log.Logf("Broker [%s] Listening on %s", config.Broker.String(), config.Broker.Address())
baddr := strings.Join(config.Broker.Options().Addrs, ",")
bname := config.Broker.String()
log.Logf("Broker [%s] Listening on %s", bname, baddr)
// announce self to the world
if err := g.Register(); err != nil {

View File

@ -500,7 +500,10 @@ func (s *rpcServer) Start() error {
return err
}
log.Logf("Broker [%s] Connected to %s", config.Broker.String(), config.Broker.Address())
baddr := strings.Join(config.Broker.Options().Addrs, ",")
bname := config.Broker.String()
log.Logf("Broker [%s] Connected to %s", bname, baddr)
// use RegisterCheck func before register
if err = s.opts.RegisterCheck(s.opts.Context); err != nil {