Skip to content

Commit

Permalink
Add error to message bus publish api
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiazlo committed Apr 10, 2019
1 parent 9161b1f commit 397d95d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions gossip/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type MessageBus struct {
// publish will create a goroutine per message sent, and
// will not time out.
//
func (eb *MessageBus) Publish(msg *Message) {
func (eb *MessageBus) Publish(msg *Message) error {
eb.rm.RLock()
defer eb.rm.RUnlock()
if chans := eb.pool[msg.Kind]; len(chans) > 0 {
Expand All @@ -68,9 +68,10 @@ func (eb *MessageBus) Publish(msg *Message) {
s <- msg
}
}(msg, channels)
} else {
log.Debugf("Agent message bus publising message: no subscribers for message kind %d ", msg.Kind)
return nil
}
log.Infof("Agent message bus publising message: no subscribers for message kind %d ", msg.Kind)
return NoSubscribersFound
}

// Subscribe add a subscriber to the its correspondant pool.
Expand Down
1 change: 1 addition & 0 deletions gossip/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ package gossip
import "errors"

var ChTimedOut error = errors.New("Timeout sending data to channel")
var NoSubscribersFound error = errors.New("No subscribers found")

0 comments on commit 397d95d

Please sign in to comment.