-
Notifications
You must be signed in to change notification settings - Fork 1
/
args.go
158 lines (132 loc) · 3.62 KB
/
args.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package rabbitmqclient
import (
"github.com/streadway/amqp"
)
// Publish specifies the arguments to publish function
type Publish struct {
Exchange string
Key string
OtherPublish
}
// SetExchange is a setter.
func (p *Publish) SetExchange(exchange string) *Publish {
p.Exchange = exchange
return p
}
// SetKey is a setter.
func (p *Publish) SetKey(key string) *Publish {
p.Key = key
return p
}
// SetOtherPublish is a setter.
func (p *Publish) SetOtherPublish(publish OtherPublish) *Publish {
p.OtherPublish = publish
return p
}
// OtherPublish specifies the others arg for the publish function.
type OtherPublish struct {
Mandatory bool
Immediate bool
Msg amqp.Publishing
}
// SetMandatory is a setter.
func (op *OtherPublish) SetMandatory(mandatory bool) *OtherPublish {
op.Mandatory = mandatory
return op
}
// SetImmediate is a setter.
func (op *OtherPublish) SetImmediate(immediate bool) *OtherPublish {
op.Immediate = immediate
return op
}
// SetMsg is a setter.
func (op *OtherPublish) SetMsg(msg amqp.Publishing) *OtherPublish {
op.Msg = msg
return op
}
// Method list for publishing body
// SetContentType sets the content type of message.
func (op *OtherPublish) SetContentType(contentType string) *OtherPublish {
op.Msg.ContentType = contentType
return op
}
// SetContentEncoding sets the content encoding of the payload.
func (op *OtherPublish) SetContentEncoding(contentEncoding string) *OtherPublish {
op.Msg.ContentEncoding = contentEncoding
return op
}
// SetPersistent sets the delivery mode to persistent.
func (op *OtherPublish) SetPersistent() *OtherPublish {
op.Msg.DeliveryMode = DeliveryModePersistent
return op
}
// SetBody sets the body payload of publish message.
func (op *OtherPublish) SetBody(payload []byte) *OtherPublish {
op.Msg.Body = payload
return op
}
// SetHeaders sets the headers for the amqp rabbitmq message.
func (op *OtherPublish) SetHeaders(header amqp.Table) *OtherPublish {
op.Msg.Headers = header
return op
}
// SetPriority sets the priority of the message.
func (op *OtherPublish) SetPriority(priority uint8) *OtherPublish {
op.Msg.Priority = priority
return op
}
// SetReplyTo sets the reply address for the RPC.
func (op *OtherPublish) SetReplyTo(replyTo string) *OtherPublish {
op.Msg.ReplyTo = replyTo
return op
}
// SetExpiration sets the message expiration specification.
func (op *OtherPublish) SetExpiration(expiration string) *OtherPublish {
op.Msg.Expiration = expiration
return op
}
// Consume define the consume arguments of amqp.
type Consume struct {
Queue string
Consumer string
AutoAck bool
Exclusive bool
NoLocal bool
NoWait bool
Args amqp.Table
}
// SetQueue sets the queue name of the consume arguments.
func (c *Consume) SetQueue(name string) *Consume {
c.Queue = name
return c
}
// SetConsumer sets the name of the consumer.
func (c *Consume) SetConsumer(name string) *Consume {
c.Consumer = name
return c
}
// SetAutoAck sets the auto ack to true for automatic acknowledgement.
func (c *Consume) SetAutoAck(autoAck bool) *Consume {
c.AutoAck = autoAck
return c
}
// SetExclusive sets the exclusive attribute to the consumer.
func (c *Consume) SetExclusive(exclusive bool) *Consume {
c.Exclusive = exclusive
return c
}
// SetNoLocal sets the no local attribute of consumer.
func (c *Consume) SetNoLocal(noLocal bool) *Consume {
c.NoLocal = noLocal
return c
}
// SetNoWait sets the no wait attribute when consuming.
func (c *Consume) SetNoWait(noWait bool) *Consume {
c.NoWait = noWait
return c
}
// SetArgs sets the args of the consume function in amqp.
func (c *Consume) SetArgs(args amqp.Table) *Consume {
c.Args = args
return c
}