Skip to content

Commit

Permalink
Lets make advert channel buffered so we don't lose adverts
Browse files Browse the repository at this point in the history
  • Loading branch information
milosgajdos committed Sep 5, 2019
1 parent bc6187e commit bb595c8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions router/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/google/uuid"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/util/log"
)

const (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bb595c8

Please sign in to comment.