-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathacknowledger.go
37 lines (31 loc) · 1.09 KB
/
acknowledger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package amqprpc
import (
amqp "github.com/rabbitmq/amqp091-go"
)
// AwareAcknowledger implements the amqp.Acknowledger interface with the
// addition that it can tell if a message has been acked in any way.
type AwareAcknowledger struct {
Acknowledger amqp.Acknowledger
Handled bool
}
// NewAwareAcknowledger returns the passed acknowledger as an AwareAcknowledger.
func NewAwareAcknowledger(acknowledger amqp.Acknowledger) *AwareAcknowledger {
return &AwareAcknowledger{
Acknowledger: acknowledger,
}
}
// Ack passes the Ack down to the underlying Acknowledger.
func (a *AwareAcknowledger) Ack(tag uint64, multiple bool) error {
a.Handled = true
return a.Acknowledger.Ack(tag, multiple)
}
// Nack passes the Nack down to the underlying Acknowledger.
func (a *AwareAcknowledger) Nack(tag uint64, multiple, requeue bool) error {
a.Handled = true
return a.Acknowledger.Nack(tag, multiple, requeue)
}
// Reject passes the Reject down to the underlying Acknowledger.
func (a *AwareAcknowledger) Reject(tag uint64, requeue bool) error {
a.Handled = true
return a.Acknowledger.Reject(tag, requeue)
}