forked from ISADBA/go-queue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
55 lines (47 loc) · 1.44 KB
/
config.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
package rabbitmq
import "fmt"
type RabbitConf struct {
Username string
Password string
Host string
Port int
VHost string `json:",optional"`
}
type RabbitListenerConf struct {
RabbitConf
ListenerQueues []ConsumerConf
}
type ConsumerConf struct {
Name string
AutoAck bool `json:",default=true"`
Exclusive bool `json:",default=false"`
// Set to true, which means that messages sent by producers in the same connection
// cannot be delivered to consumers in this connection.
NoLocal bool `json:",default=false"`
// Whether to block processing
NoWait bool `json:",default=false"`
}
type RabbitSenderConf struct {
RabbitConf
ContentType string `json:",default=text/plain"` // MIME content type
}
type QueueConf struct {
Name string
Durable bool `json:",default=true"`
AutoDelete bool `json:",default=false"`
Exclusive bool `json:",default=false"`
NoWait bool `json:",default=false"`
}
type ExchangeConf struct {
ExchangeName string
Type string `json:",options=direct|fanout|topic|headers"` // exchange type
Durable bool `json:",default=true"`
AutoDelete bool `json:",default=false"`
Internal bool `json:",default=false"`
NoWait bool `json:",default=false"`
Queues []QueueConf
}
func getRabbitURL(rabbitConf RabbitConf) string {
return fmt.Sprintf("amqp://%s:%s@%s:%d/%s", rabbitConf.Username, rabbitConf.Password,
rabbitConf.Host, rabbitConf.Port, rabbitConf.VHost)
}