-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconstants.go
More file actions
94 lines (72 loc) · 2.67 KB
/
Copy pathconstants.go
File metadata and controls
94 lines (72 loc) · 2.67 KB
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
package harego
import amqp "github.com/rabbitmq/amqp091-go"
//go:generate stringer -type=AckType,DeliveryMode -output=constants_string.go
// AckType specifies how the message is acknowledged to RabbotMQ.
type AckType int
const (
// AckTypeAck causes the message to be removed in broker. The multiple value
// is false, causing the broker to act on one message.
AckTypeAck AckType = iota
// AckTypeNack causes the message to be requeued in broker. The multiple
// value is false, causing the broker to act on one message.
AckTypeNack
// AckTypeReject causes the message to be dropped in broker. AckTypeNack
// must not be used to select or requeue messages the client wishes not to
// handle, rather it is to inform the server that the client is incapable
// of handling this message at this time.
AckTypeReject
// AckTypeRequeue causes the message to be requeued back to the end of the
// queue.
AckTypeRequeue
_invalidAckType
)
// IsValid returns true if the object is within the valid boundries.
func (a AckType) IsValid() bool {
return a < _invalidAckType && a >= 0
}
// ExchangeType is the kind of exchange.
type ExchangeType int
const (
// ExchangeTypeDirect defines a direct exchange.
ExchangeTypeDirect ExchangeType = iota
// ExchangeTypeFanout defines a fanout exchange.
ExchangeTypeFanout
// ExchangeTypeTopic defines a topic exchange.
ExchangeTypeTopic
// ExchangeTypeHeaders defines a headers exchange.
ExchangeTypeHeaders
_invalidExchangeType
)
// IsValid returns true if the object is within the valid boundries.
func (e ExchangeType) IsValid() bool {
return e < _invalidExchangeType && e >= 0
}
func (e ExchangeType) String() string {
switch e { //nolint:exhaustive // I don't want to panic here.
case ExchangeTypeDirect:
return "direct"
case ExchangeTypeFanout:
return "fanout"
case ExchangeTypeTopic:
return "topic"
case ExchangeTypeHeaders:
return "headers"
}
return ""
}
// DeliveryMode is the DeliveryMode of a amqp.Publishing message.
type DeliveryMode uint8
const (
// DeliveryModeTransient means higher throughput but messages will not be
// restored on broker restart. The delivery mode of publishings is
// unrelated to the durability of the queues they reside on. Transient
// messages will not be restored to durable queues.
DeliveryModeTransient = DeliveryMode(amqp.Transient)
// DeliveryModePersistent messages will be restored to durable queues and
// lost on non-durable queues during server restart.
DeliveryModePersistent = DeliveryMode(amqp.Persistent)
)
// IsValid returns true if the object is within the valid boundries.
func (d DeliveryMode) IsValid() bool {
return d == DeliveryModePersistent || d == DeliveryModeTransient
}