Skip to content

Commit

Permalink
✨ Remove PushData() and add PopOpts() methods (#17)
Browse files Browse the repository at this point in the history
Closes #16
  • Loading branch information
Bigomby committed Oct 18, 2016
1 parent 984a150 commit 284371b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ func (m *message) PopData() (ret []byte, err error) {
return
}

// PopData get the data stored by the previous handler
func (m *message) PopOpts() (ret map[string]interface{}, err error) {
if m.opts.Empty() {
err = errors.New("Empty stack")
return
}
ret = m.opts.Pop().(map[string]interface{})

return
}

func (m message) GetReports() []Report {
var reports []Report

Expand Down
3 changes: 2 additions & 1 deletion rbforwarder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ func (c *MockMiddleComponent) OnMessage(
c.Called(m)
data, _ := m.PopData()
processedData := "-> [" + string(data) + "] <-"
m.PushData([]byte(processedData))
message := m.(*message)
message.PushData([]byte(processedData))
next(m)

}
Expand Down
2 changes: 1 addition & 1 deletion types/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package types
// Messenger is used by modules to handle messages
type Messenger interface {
PopData() ([]byte, error)
PushData(data []byte)
PopOpts() (map[string]interface{}, error)
}

0 comments on commit 284371b

Please sign in to comment.