Debian Codegraph @

amqptest/server/delivery.go

raw
1 package server
2
3 import (
4 "time"
5
6 "github.com/NeowayLabs/wabbit"
7 )
8
9 type (
10 // Delivery is an interface to delivered messages
11 Delivery struct {
12 data []byte
13 headers wabbit.Option
14 tag uint64
15 consumerTag string
16 originalRoute string
17 messageId string
18 channel *Channel
19 contentType string
20 }
21 )
22
23 func NewDelivery(ch *Channel, data []byte, tag uint64, messageId string, hdrs wabbit.Option, contentType string) *Delivery {
24 return &Delivery{
25 data: data,
26 headers: hdrs,
27 channel: ch,
28 tag: tag,
29 messageId: messageId,
30 contentType: contentType,
31 }
32 }
33
34 func (d *Delivery) Ack(multiple bool) error {
35 return d.channel.Ack(d.tag, multiple)
36 }
37
38 func (d *Delivery) Nack(multiple, requeue bool) error {
39 return d.channel.Nack(d.tag, multiple, requeue)
40 }
41
42 func (d *Delivery) Reject(requeue bool) error {
43 return d.channel.Nack(d.tag, false, requeue)
44 }
45
46 func (d *Delivery) Body() []byte {
47 return d.data
48 }
49
50 func (d *Delivery) Headers() wabbit.Option {
51 return d.headers
52 }
53
54 func (d *Delivery) DeliveryTag() uint64 {
55 return d.tag
56 }
57
58 func (d *Delivery) ConsumerTag() string {
59 return d.consumerTag
60 }
61
62 func (d *Delivery) MessageId() string {
63 return d.messageId
64 }
65
66 func (d *Delivery) Timestamp() time.Time {
67 return time.Now()
68 }
69
70 func (d *Delivery) ContentType() string {
71 return d.contentType
72 }