-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
76 lines (64 loc) · 1.69 KB
/
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
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
package main
import (
"fmt"
"goexamples/kafka/msgMiddleware/kafka"
"goexamples/kafka/msgMiddleware/model"
"goexamples/kafka/msgMiddleware/server"
log "github.com/Sirupsen/logrus"
)
var (
cfg *model.Config = &model.Config{
KafkaServer: []string{"172.16.9.229:9029"},
KafkaTopics: []model.TopicInfo{
{Name: "tes2", Partitions: 1},
{Name: "tes2", Partitions: 2},
{Name: "tes2", Partitions: 3},
},
//KafkaConsumerGroupId: "test-consumer-group",
ConsumerGroupList: []model.ConsumerGroupInfo{
{Topic: []string{"tes2"}, GroupId: "test-consumer-group1", Retries: 3, Timeout: 3},
{Topic: []string{"tes2"}, GroupId: "test-consumer-group2", Retries: 3, Timeout: 3},
},
HttpServerPort: 8090,
HttpServerReadTimeout: 5000,
HttpServerWriteTimeout: 5000,
HttpServerHandlerChannelSize: 500,
}
)
func main() {
log.SetLevel(log.DebugLevel)
//cfgFlg := flag.String("c", "./cfgfile/cfg.json", "configuration file")
//flag.Parse()
//
//err := g.ParseConfig(*cfgFlg)
//if err != nil {
// log.Println("parse config is failed :", err)
// return
//}
//
//cfg = g.Config()
fmt.Println("start producer... ")
producer, err := kafka.CreateProducer(cfg)
if err != nil {
log.Error("create produce error :", err)
return
}
fmt.Println("start Consumer... ")
//consumption := kafka.NewConsumption(cfg)
//err = consumption.CreateConsume()
//if err != nil {
// log.Error("consumption error :", err)
// return
//}
_, err = kafka.CreateConsumerGroup(cfg)
if err != nil {
fmt.Println("create consumer error.")
return
}
log.Info("server start...")
runFlg := server.RunHttpServer(producer, cfg)
if !runFlg {
log.Panic("server run error !")
}
select {}
}