-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqueue.go
65 lines (55 loc) · 2.02 KB
/
queue.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
package alice
import "github.com/streadway/amqp"
// Queue models a RabbitMQ queue
type Queue struct {
exchange *Exchange // The exchange this queue will be bound to
name string // Name of the queue
durable bool // Does this queue persist during broker restarts?
exclusive bool // Is this queue exclusive to one consumer? This also sets autoDelete to true.
autoDelete bool // Does this queue get deleted when no-one is consuming from it?
noWait bool // Should we skip waiting for an acknowledgement from the broker?
bindingKey string // The key with which this queue is bound to the exchange
args amqp.Table // Additional amqp arguments to configure the exchange
}
// CreateDefaultQueue creates and returns a queue with the following parameters:
// durable: true, exclusive, false, autoDelete: false, noWait: false, args: nil
func CreateDefaultQueue(exchange *Exchange, name string) *Queue {
return CreateQueue(exchange, name, true, false, false, false, nil)
}
// CreateQueue returns a queue created with the accompanied specifications
func CreateQueue(exchange *Exchange, name string, durable bool, exclusive bool, autoDelete bool, noWait bool, arguments amqp.Table) *Queue {
q := &Queue{
exchange: exchange,
name: name,
durable: durable,
exclusive: exclusive,
autoDelete: autoDelete,
noWait: noWait,
args: arguments,
}
return q
}
// SetName sets the queue name
func (q *Queue) SetName(name string) {
q.name = name
}
// SetDurable set exchange durability
func (q *Queue) SetDurable(durable bool) {
q.durable = durable
}
// SetExclusive sets queue exclusivity
func (q *Queue) SetExclusive(exclusive bool) {
q.exclusive = exclusive
}
// SetAutoDelete sets queue auto deletion
func (q *Queue) SetAutoDelete(autoDelete bool) {
q.autoDelete = autoDelete
}
// SetNoWait sets the noWait flag
func (q *Queue) SetNoWait(noWait bool) {
q.noWait = noWait
}
// SetArgs sets additional queue arguments
func (q *Queue) SetArgs(args amqp.Table) {
q.args = args
}