-
Notifications
You must be signed in to change notification settings - Fork 31
/
kafka_sink.go
47 lines (41 loc) · 1.35 KB
/
kafka_sink.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
package v1alpha1
import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
type KafkaSink struct {
Kafka `json:",inline" protobuf:"bytes,1,opt,name=kafka"`
Async bool `json:"async,omitempty" protobuf:"varint,2,opt,name=async"`
// +kubebuilder:default="100Ki"
BatchSize *resource.Quantity `json:"batchSize,omitempty" protobuf:"bytes,3,opt,name=batchSize"`
Linger *metav1.Duration `json:"linger,omitempty" protobuf:"bytes,4,opt,name=linger"`
// +kubebuilder:default="lz4"
CompressionType string `json:"compressionType,omitempty" protobuf:"bytes,5,opt,name=compressionType"`
// +kubebuilder:default="all"
Acks *intstr.IntOrString `json:"acks,omitempty" protobuf:"bytes,6,opt,name=acks"`
// +kubebuilder:default=true
EnableIdempotence bool `json:"enableIdempotence,omitempty" protobuf:"varint,7,opt,name=enableIdempotence"`
}
func (m *KafkaSink) GetBatchSize() int {
return int(m.BatchSize.Value())
}
func (m *KafkaSink) GetLingerMs() int {
if m.Linger == nil {
if m.Async {
return 5
} else {
return 0
}
}
return int(m.Linger.Milliseconds())
}
func (m *KafkaSink) GetAcks() interface{} {
if m.Acks.Type == intstr.String {
return m.Acks.String()
}
return m.Acks.IntValue()
}
func (m *KafkaSink) GetMessageMaxBytes() int {
return m.Kafka.GetMessageMaxBytes()
}