/
config.go
34 lines (31 loc) · 1.2 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
package kafka
import (
"github.com/americanas-go/config"
"github.com/segmentio/kafka-go"
"time"
)
const (
root = "faas.kafka"
topics = root + ".topics"
groupId = root + ".groupId"
brokers = root + ".brokers"
concurrency = root + ".concurrency"
queueCapacity = root + ".queueCapacity"
minBytes = root + ".minBytes"
maxBytes = root + ".maxBytes"
startOffset = root + ".startOffset"
readBatchTimeout = root + ".readBatchTimeout"
maxWait = root + ".maxWait"
)
func init() {
config.Add(topics, []string{"changeme"}, "kafka listener topics")
config.Add(brokers, []string{"localhost:9090"}, "kafka listener brokers")
config.Add(groupId, "changeme", "kafka listener groupId")
config.Add(concurrency, 10, "kafka listener concurrency")
config.Add(queueCapacity, 100, "defines queue capacity")
config.Add(minBytes, 1, "defines batch min bytes")
config.Add(maxBytes, 10485760, "defines batch max bytes")
config.Add(readBatchTimeout, 2*time.Second, "defines read batch timeout")
config.Add(maxWait, 2*time.Second, "defines max wait")
config.Add(startOffset, kafka.LastOffset, "defines start offset LastOffset=-1, FirstOffset=-2")
}