Skip to content

Commit

Permalink
Revert "Support for AutoAckOff"
Browse files Browse the repository at this point in the history
This reverts commit e28a1db.
  • Loading branch information
shivamkm07 committed Oct 13, 2022
1 parent e28a1db commit 7b1c0eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
12 changes: 0 additions & 12 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ type Message interface {
MessageID() uint16
Payload() []byte
Ack()
NoAutoAck() bool
AutoAckOff()
}

type message struct {
Expand All @@ -49,7 +47,6 @@ type message struct {
payload []byte
once sync.Once
ack func()
noautoack bool
}

func (m *message) Duplicate() bool {
Expand Down Expand Up @@ -80,14 +77,6 @@ func (m *message) Ack() {
m.once.Do(m.ack)
}

func (m *message) NoAutoAck() bool {
return m.noautoack
}

func (m *message) AutoAckOff() {
m.noautoack = true
}

func messageFromPublish(p *packets.PublishPacket, ack func()) Message {
return &message{
duplicate: p.Dup,
Expand All @@ -97,7 +86,6 @@ func messageFromPublish(p *packets.PublishPacket, ack func()) Message {
messageID: p.MessageID,
payload: p.Payload,
ack: ack,
noautoack: false,
}
}

Expand Down
12 changes: 3 additions & 9 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order
wg.Add(1)
go func() {
hd(client, m)
if !m.NoAutoAck() {
m.Ack()
}
m.Ack()
wg.Done()
}()
}
Expand All @@ -203,9 +201,7 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order
wg.Add(1)
go func() {
r.defaultHandler(client, m)
if !m.NoAutoAck() {
m.Ack()
}
m.Ack()
wg.Done()
}()
}
Expand All @@ -216,9 +212,7 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order
r.RUnlock()
for _, handler := range handlers {
handler(client, m)
if !m.NoAutoAck() {
m.Ack()
}
m.Ack()
}
// DEBUG.Println(ROU, "matchAndDispatch handled message")
}
Expand Down

0 comments on commit 7b1c0eb

Please sign in to comment.