Skip to content

Commit

Permalink
event: guarantee the order on which events are delivered
Browse files Browse the repository at this point in the history
Now instead of guaranteeing that the message will be eventually
delivered (even if channels are full), we guarantee that they will be
delivered in order, as long as the listener channels aren't full.
  • Loading branch information
fsouza committed Jul 26, 2017
1 parent 78dd980 commit 6854512
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (eventState *eventMonitoringState) monitorEvents(c *Client) {
return
}
eventState.updateLastSeen(ev)
go eventState.sendEvent(ev)
eventState.sendEvent(ev)
case err = <-eventState.errC:
if err == ErrNoListeners {
eventState.disableEventMonitoring()
Expand Down Expand Up @@ -274,7 +274,10 @@ func (eventState *eventMonitoringState) sendEvent(event *APIEvents) {
}

for _, listener := range eventState.listeners {
listener <- event
select {
case listener <- event:
default:
}
}
}
}
Expand Down

0 comments on commit 6854512

Please sign in to comment.