-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (29 loc) · 792 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
package main
import (
"fmt"
"github.com/ragul28/rabbitmq-benchmark/queue"
"github.com/ragul28/rabbitmq-benchmark/utils"
)
func main() {
cfg := utils.LoadFlags()
fmt.Println("Runing as", cfg.Role)
switch cfg.Role {
case "consumer":
// Start consumer worker threads using goroutine
for w := 1; w <= cfg.NumWorker; w++ {
fmt.Printf("Consumer Worker %d started..\n", w)
go queue.ConsumerMQ(cfg)
}
case "producer":
// Start publisher worker threads using goroutine
for w := 1; w <= cfg.NumWorker; w++ {
fmt.Printf("Publisher Worker %d started..\n", w)
go queue.PublishMQ(cfg)
}
default:
fmt.Printf("Not a valid role, Please choose consumer / publisher")
}
utils.CloserHandler()
// Block main thread to allow running goroutines forever.
select {}
}