mv src/common src/utils src/grpc-etcdv3 to pkg

This commit is contained in:
xmcy0011
2021-10-11 22:12:01 +08:00
parent bc94d4e0b3
commit 737edb985b
119 changed files with 310 additions and 702 deletions
+36
View File
@@ -0,0 +1,36 @@
package kafka
import (
"github.com/Shopify/sarama"
"sync"
)
type Consumer struct {
addr []string
WG sync.WaitGroup
Topic string
PartitionList []int32
Consumer sarama.Consumer
}
func NewKafkaConsumer(addr []string, topic string) *Consumer {
p := Consumer{}
p.Topic = topic
p.addr = addr
consumer, err := sarama.NewConsumer(p.addr, nil)
if err != nil {
panic(err)
return nil
}
p.Consumer = consumer
partitionList, err := consumer.Partitions(p.Topic)
if err != nil {
panic(err)
return nil
}
p.PartitionList = partitionList
return &p
}