Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove PushData() and add PopOpts() methods #17

Merged
merged 1 commit into from
Aug 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}