Skip to content

Commit

Permalink
switch to buffered chan, due to multiple contemporaneus events
Browse files Browse the repository at this point in the history
  • Loading branch information
led0nk committed Jun 10, 2024
1 parent 4ff7459 commit dcbf3fd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/events/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (e *EventManager) Subscribe(name string) (uuid.UUID, <-chan EventMessage) {
return uuid.Nil, nil
}

ch := make(chan EventMessage)
ch := make(chan EventMessage, 5)
e.subscriber[id] = ch

e.logger.Info("service subscribed to eventManager", "service id", id, "service name", name)
Expand All @@ -65,6 +65,7 @@ func (e *EventManager) Publish(emsg EventMessage) {
case ch <- emsg:
e.logger.Debug("publish eventMessage", "debug", "publish", subscriber.String(), fmt.Sprintf("%s", emsg))
default:
e.logger.Debug("channel blocked, skipping subscriber", "subscriber", subscriber.String())
}
}
}
Expand Down

0 comments on commit dcbf3fd

Please sign in to comment.