Skip to content

Commit 5ec67f6

Browse files
authored
feat: Make Kafka group.id configurable. Fixes #89 (#464)
Signed-off-by: Alex Collins <[email protected]>
1 parent 782c39a commit 5ec67f6

File tree

15 files changed

+264
-151
lines changed

15 files changed

+264
-151
lines changed

api/v1alpha1/generated.pb.go

Lines changed: 185 additions & 144 deletions
Large diffs are not rendered by default.

api/v1alpha1/generated.proto

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/kafka_source.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ type KafkaSource struct {
1313
FetchMin *resource.Quantity `json:"fetchMin,omitempty" protobuf:"bytes,3,opt,name=fetchMin"`
1414
// +kubebuilder:default="500ms"
1515
FetchWaitMax *metav1.Duration `json:"fetchWaitMax,omitempty" protobuf:"bytes,4,opt,name=fetchWaitMax"`
16+
// GroupID is the consumer group ID. If not specified, a unique deterministic group ID is generated.
17+
GroupID string `json:"groupId,omitempty" protobuf:"bytes,5,opt,name=groupId"`
1618
}
1719

1820
func (m *KafkaSource) GetAutoOffsetReset() string {
@@ -26,3 +28,10 @@ func (m *KafkaSource) GetFetchMinBytes() int {
2628
func (m *KafkaSource) GetFetchWaitMaxMs() int {
2729
return int(m.FetchWaitMax.Milliseconds())
2830
}
31+
32+
func (m *KafkaSource) GetGroupID(defaultGroupID string) string {
33+
if m.GroupID != "" {
34+
return m.GroupID
35+
}
36+
return defaultGroupID
37+
}

api/v1alpha1/kafka_source_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,14 @@ func TestKafkaSource_GetFetchWaitMaxMs(t *testing.T) {
2424
s := KafkaSource{FetchWaitMax: &metav1.Duration{Duration: time.Second}}
2525
assert.Equal(t, 1000, s.GetFetchWaitMaxMs())
2626
}
27+
28+
func TestKafkaSource_GetGroupID(t *testing.T) {
29+
t.Run("Default", func(t *testing.T) {
30+
s := &KafkaSource{}
31+
assert.Equal(t, "foo", s.GetGroupID("foo"))
32+
})
33+
t.Run("Specified", func(t *testing.T) {
34+
s := &KafkaSource{GroupID: "bar"}
35+
assert.Equal(t, "bar", s.GetGroupID("foo"))
36+
})
37+
}

config/ci.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,6 +3646,11 @@ spec:
36463646
fetchWaitMax:
36473647
default: 500ms
36483648
type: string
3649+
groupId:
3650+
description: GroupID is the consumer group ID. If
3651+
not specified, a unique deterministic group ID is
3652+
generated.
3653+
type: string
36493654
maxMessageBytes:
36503655
format: int32
36513656
type: integer
@@ -10689,6 +10694,10 @@ spec:
1068910694
fetchWaitMax:
1069010695
default: 500ms
1069110696
type: string
10697+
groupId:
10698+
description: GroupID is the consumer group ID. If not specified,
10699+
a unique deterministic group ID is generated.
10700+
type: string
1069210701
maxMessageBytes:
1069310702
format: int32
1069410703
type: integer

config/crd/bases/dataflow.argoproj.io_pipelines.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3641,6 +3641,11 @@ spec:
36413641
fetchWaitMax:
36423642
default: 500ms
36433643
type: string
3644+
groupId:
3645+
description: GroupID is the consumer group ID. If
3646+
not specified, a unique deterministic group ID is
3647+
generated.
3648+
type: string
36443649
maxMessageBytes:
36453650
format: int32
36463651
type: integer

config/crd/bases/dataflow.argoproj.io_steps.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3468,6 +3468,10 @@ spec:
34683468
fetchWaitMax:
34693469
default: 500ms
34703470
type: string
3471+
groupId:
3472+
description: GroupID is the consumer group ID. If not specified,
3473+
a unique deterministic group ID is generated.
3474+
type: string
34713475
maxMessageBytes:
34723476
format: int32
34733477
type: integer

config/default.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,6 +3646,11 @@ spec:
36463646
fetchWaitMax:
36473647
default: 500ms
36483648
type: string
3649+
groupId:
3650+
description: GroupID is the consumer group ID. If
3651+
not specified, a unique deterministic group ID is
3652+
generated.
3653+
type: string
36493654
maxMessageBytes:
36503655
format: int32
36513656
type: integer
@@ -10689,6 +10694,10 @@ spec:
1068910694
fetchWaitMax:
1069010695
default: 500ms
1069110696
type: string
10697+
groupId:
10698+
description: GroupID is the consumer group ID. If not specified,
10699+
a unique deterministic group ID is generated.
10700+
type: string
1069210701
maxMessageBytes:
1069310702
format: int32
1069410703
type: integer

config/dev.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,6 +3646,11 @@ spec:
36463646
fetchWaitMax:
36473647
default: 500ms
36483648
type: string
3649+
groupId:
3650+
description: GroupID is the consumer group ID. If
3651+
not specified, a unique deterministic group ID is
3652+
generated.
3653+
type: string
36493654
maxMessageBytes:
36503655
format: int32
36513656
type: integer
@@ -10689,6 +10694,10 @@ spec:
1068910694
fetchWaitMax:
1069010695
default: 500ms
1069110696
type: string
10697+
groupId:
10698+
description: GroupID is the consumer group ID. If not specified,
10699+
a unique deterministic group ID is generated.
10700+
type: string
1069210701
maxMessageBytes:
1069310702
format: int32
1069410703
type: integer

config/quick-start.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,6 +3646,11 @@ spec:
36463646
fetchWaitMax:
36473647
default: 500ms
36483648
type: string
3649+
groupId:
3650+
description: GroupID is the consumer group ID. If
3651+
not specified, a unique deterministic group ID is
3652+
generated.
3653+
type: string
36493654
maxMessageBytes:
36503655
format: int32
36513656
type: integer
@@ -10689,6 +10694,10 @@ spec:
1068910694
fetchWaitMax:
1069010695
default: 500ms
1069110696
type: string
10697+
groupId:
10698+
description: GroupID is the consumer group ID. If not specified,
10699+
a unique deterministic group ID is generated.
10700+
type: string
1069210701
maxMessageBytes:
1069310702
format: int32
1069410703
type: integer

0 commit comments

Comments
 (0)