-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
49 lines (42 loc) · 1013 Bytes
/
main.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
package main
import (
"os"
"strings"
)
func main() {
workers := make(map[string]*RMQWorker)
loadConfiguration()
for _, queue := range strings.Fields(os.Getenv("QUEUES")) {
workers[queue] = NewWorker(queue)
workers[queue].startConsumer()
}
}
func loadConfiguration() {
if os.Getenv("RABBITMQ_USER") == "" {
os.Setenv("RABBITMQ_USER", "guest")
}
if os.Getenv("RABBITMQ_PASSWORD") == "" {
os.Setenv("RABBITMQ_PASSWORD", "guest")
}
if os.Getenv("RABBITMQ_HOST") == "" {
os.Setenv("RABBITMQ_HOST", "localhost")
}
if os.Getenv("RABBITMQ_PORT") == "" {
os.Setenv("RABBITMQ_PORT", "5672")
}
if os.Getenv("MONGODB_HOST") == "" {
os.Setenv("MONGODB_HOST", "localhost")
}
if os.Getenv("MONGODB_PORT") == "" {
os.Setenv("MONGODB_PORT", "27017")
}
if os.Getenv("MONGODB_DB") == "" {
os.Setenv("MONGODB_DB", "amqp")
}
if os.Getenv("MONGODB_COLLECTION") == "" {
os.Setenv("MONGODB_COLLECTION", "messages")
}
if os.Getenv("QUEUES") == "" {
os.Setenv("QUEUES", "messages")
}
}