From bb595c85b2bb93274717337b6251a0d8c99e2538 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Thu, 5 Sep 2019 19:05:47 +0100 Subject: [PATCH] Lets make advert channel buffered so we don't lose adverts --- router/default.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/router/default.go b/router/default.go index 2294a149..cfc30548 100644 --- a/router/default.go +++ b/router/default.go @@ -10,6 +10,7 @@ import ( "github.com/google/uuid" "github.com/micro/go-micro/registry" + "github.com/micro/go-micro/util/log" ) const ( @@ -289,6 +290,7 @@ func (r *router) publishAdvert(advType AdvertType, events []*Event) { Events: events, } + log.Debugf("Router publishing advert; %+v", a) r.RLock() for _, sub := range r.subscribers { // check the exit chan first @@ -601,7 +603,7 @@ func (r *router) Advertise() (<-chan *Advert, error) { switch r.status.Code { case Advertising: - advertChan := make(chan *Advert) + advertChan := make(chan *Advert, 128) r.subscribers[uuid.New().String()] = advertChan return advertChan, nil case Running: @@ -641,7 +643,7 @@ func (r *router) Advertise() (<-chan *Advert, error) { r.status = Status{Code: Advertising, Error: nil} // create advert channel - advertChan := make(chan *Advert) + advertChan := make(chan *Advert, 128) r.subscribers[uuid.New().String()] = advertChan return advertChan, nil