Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Use a constructor for MessageIterator
Browse files Browse the repository at this point in the history
This allows creating MessageIterators for tests
  • Loading branch information
fionera authored and mougams committed Nov 7, 2023
1 parent 4470942 commit f700670
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ type MessageIterator struct {
Message Message
}

func NewMessageIterator(b []byte) *MessageIterator {
return &MessageIterator{
b: b,
Message: Message{
Args: &ArgIterator{
b: b,
},
},
}
}

func (i *MessageIterator) Error() error {
return i.err
}
Expand Down Expand Up @@ -97,14 +108,7 @@ func (i *MessageIterator) Next() bool {
}

func (c *conn) handleNotify(f Frame, acks chan Frame) error {
messages := &MessageIterator{
b: f.data,
Message: Message{
Args: &ArgIterator{
b: f.data,
},
},
}
messages := NewMessageIterator(f.data)

actions, err := c.handler(messages)
if err != nil {
Expand Down

0 comments on commit f700670

Please sign in to comment.