-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconstants.go
118 lines (93 loc) · 2.56 KB
/
constants.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
package gorabbit
import (
"errors"
"time"
)
// Library name.
const libraryName = "Gorabbit"
// Connection protocols.
const (
defaultProtocol = "amqp"
securedProtocol = "amqps"
)
// Default values for the ClientOptions and ManagerOptions.
const (
defaultHost = "127.0.0.1"
defaultPort = 5672
defaultUsername = "guest"
defaultPassword = "guest"
defaultVhost = ""
defaultUseTLS = false
defaultKeepAlive = true
defaultRetryDelay = 3 * time.Second
defaultMaxRetry = 5
defaultPublishingCacheTTL = 60 * time.Second
defaultPublishingCacheSize = 128
defaultMode = Release
)
var defaultMarshaller = NewJSONMarshaller()
// Default values for the amqp Config.
const (
defaultHeartbeat = 10 * time.Second
defaultLocale = "en_US"
)
const (
xDeathCountHeader = "x-death-count"
)
// Connection Types.
type connectionType string
const (
connectionTypeConsumer connectionType = "consumer"
connectionTypePublisher connectionType = "publisher"
)
// Exchange Types
type ExchangeType string
const (
ExchangeTypeTopic ExchangeType = "topic"
ExchangeTypeDirect ExchangeType = "direct"
ExchangeTypeFanout ExchangeType = "fanout"
ExchangeTypeHeaders ExchangeType = "headers"
)
func (e ExchangeType) String() string {
return string(e)
}
// Priority Levels.
type MessagePriority uint8
const (
PriorityLowest MessagePriority = 1
PriorityVeryLow MessagePriority = 2
PriorityLow MessagePriority = 3
PriorityMedium MessagePriority = 4
PriorityHigh MessagePriority = 5
PriorityHighest MessagePriority = 6
)
func (m MessagePriority) Uint8() uint8 {
return uint8(m)
}
// Delivery Modes.
type DeliveryMode uint8
const (
Transient DeliveryMode = 1
Persistent DeliveryMode = 2
)
func (d DeliveryMode) Uint8() uint8 {
return uint8(d)
}
// Logging Modes.
const (
Release = "release"
Debug = "debug"
)
func isValidMode(mode string) bool {
return mode == Release || mode == Debug
}
// Errors.
var (
errEmptyURI = errors.New("amqp uri is empty")
errChannelClosed = errors.New("channel is closed")
errConnectionClosed = errors.New("connection is closed")
errConsumerAlreadyExists = errors.New("consumer already exists")
errConsumerConnectionNotInitialized = errors.New("consumerConnection is not initialized")
errPublisherConnectionNotInitialized = errors.New("publisherConnection is not initialized")
errEmptyQueue = errors.New("queue is empty")
)