Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.24

- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Start containers
run: make integration-compose

- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Integration Test
run: go test -timeout=15m -v test/integration/integration_test.go
env:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- run: git tag ${{ github.event.inputs.tag }}

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.24

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.24

- name: Install dependencies
run: go get .

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.51
version: v1.64.8
args: -c .golangci.yml --timeout=5m -v

- name: Build
Expand Down
8 changes: 1 addition & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ linters:
disable-all: true
enable:
- bodyclose
- depguard
- errcheck
- dupl
- exhaustive
Expand Down Expand Up @@ -37,7 +36,7 @@ linters:
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: internal/kafka/
- path: internal/
text: "dot-imports"
linters:
- revive
Expand All @@ -48,8 +47,3 @@ issues:
linters:
- errcheck
- funlen

service:
golangci-lint-version: 1.51.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ help:
## lint: runs golangci lint based on .golangci.yml configuration
.PHONY: lint
lint:
@if ! test -f `go env GOPATH`/bin/golangci-lint; then go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0; fi
@if ! test -f `go env GOPATH`/bin/golangci-lint; then go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8; fi
golangci-lint run -c .golangci.yml --fix -v

## test: runs tests
Expand Down
2 changes: 1 addition & 1 deletion examples/multiple-consumer/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module multiple-consumer

go 1.19
go 1.24

replace github.com/Trendyol/kafka-cronsumer => ../..

Expand Down
2 changes: 1 addition & 1 deletion examples/single-consumer-with-backoff-strategy/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module single-consumer-with-producer

go 1.19
go 1.24

replace github.com/Trendyol/kafka-cronsumer => ../..

Expand Down
2 changes: 1 addition & 1 deletion examples/single-consumer-with-custom-logger/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module single-consumer-with-custom-logger

go 1.19
go 1.24

replace github.com/Trendyol/kafka-cronsumer => ../..

Expand Down
2 changes: 1 addition & 1 deletion examples/single-consumer-with-deadletter/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module single-consumer-with-deadletter

go 1.19
go 1.24

replace github.com/Trendyol/kafka-cronsumer => ../..

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module single-consumer

go 1.19
go 1.24

replace github.com/Trendyol/kafka-cronsumer => ../..

Expand Down
2 changes: 1 addition & 1 deletion examples/single-consumer-with-metric-collector/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module single-consumer-with-custom-logger

go 1.19
go 1.24

replace github.com/Trendyol/kafka-cronsumer => ../..

Expand Down
2 changes: 1 addition & 1 deletion examples/single-consumer-with-producer/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module single-consumer-with-producer

go 1.19
go 1.24

replace github.com/Trendyol/kafka-cronsumer => ../..

Expand Down
2 changes: 1 addition & 1 deletion examples/single-consumer/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module single-consumer

go 1.19
go 1.24

replace github.com/Trendyol/kafka-cronsumer => ../..

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Trendyol/kafka-cronsumer

go 1.19
go 1.24

require (
github.com/prometheus/client_golang v1.16.0
Expand Down
6 changes: 3 additions & 3 deletions internal/cronsumer_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Test_GetMetricsCollector(t *testing.T) {
LogLevel: "info",
}

var firstConsumerFn kafka.ConsumeFn = func(message kafka.Message) error {
var firstConsumerFn kafka.ConsumeFn = func(_ kafka.Message) error {
return nil
}

Expand Down Expand Up @@ -52,7 +52,7 @@ func Test_GetMetricsCollector(t *testing.T) {
LogLevel: "info",
}

var firstConsumerFn kafka.ConsumeFn = func(message kafka.Message) error {
var firstConsumerFn kafka.ConsumeFn = func(_ kafka.Message) error {
return nil
}

Expand Down Expand Up @@ -81,7 +81,7 @@ func Test_GetMetricsCollector(t *testing.T) {
LogLevel: "info",
}

var firstConsumerFn kafka.ConsumeFn = func(message kafka.Message) error {
var firstConsumerFn kafka.ConsumeFn = func(_ kafka.Message) error {
return nil
}

Expand Down
16 changes: 8 additions & 8 deletions internal/cronsumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Test_Produce_Max_Retry_Count_Reach(t *testing.T) {
Logger: logger.New("info"),
}

var firstConsumerFn kafka.ConsumeFn = func(message kafka.Message) error {
var firstConsumerFn kafka.ConsumeFn = func(_ kafka.Message) error {
return nil
}
c := &cronsumer{
Expand Down Expand Up @@ -60,7 +60,7 @@ func Test_Produce_Max_Retry_Count_Reach(t *testing.T) {
func Test_Produce_Max_Retry_Count_Reach_Dead_Letter_Topic_Feature_Enabled(t *testing.T) {
// Given

var firstConsumerFn kafka.ConsumeFn = func(message kafka.Message) error {
var firstConsumerFn kafka.ConsumeFn = func(_ kafka.Message) error {
return nil
}
c := &cronsumer{
Expand Down Expand Up @@ -108,7 +108,7 @@ func Test_Produce_With_Retry(t *testing.T) {
Logger: logger.New("info"),
}

var firstConsumerFn kafka.ConsumeFn = func(message kafka.Message) error {
var firstConsumerFn kafka.ConsumeFn = func(_ kafka.Message) error {
return nil
}
producer := newMockProducer()
Expand Down Expand Up @@ -155,7 +155,7 @@ func Test_Recover_Message(t *testing.T) {
Logger: logger.New("info"),
}

var firstConsumerFn kafka.ConsumeFn = func(message kafka.Message) error {
var firstConsumerFn kafka.ConsumeFn = func(_ kafka.Message) error {
return nil
}
producer := newMockProducer()
Expand Down Expand Up @@ -196,7 +196,7 @@ type mockConsumer struct{}
func (c mockConsumer) Stop() {
}

func (c mockConsumer) ReadMessage(ctx context.Context) (*segmentio.Message, error) {
func (c mockConsumer) ReadMessage(_ context.Context) (*segmentio.Message, error) {
return &segmentio.Message{}, nil
}

Expand All @@ -220,15 +220,15 @@ func newMockProducer() mockProducer {
}
}

func (k *mockProducer) ProduceWithRetryOption(message MessageWrapper, increaseRetry bool, increaseRetryAttempt bool) error {
func (k *mockProducer) ProduceWithRetryOption(_ MessageWrapper, _ bool, _ bool) error {
return nil
}

func (k *mockProducer) Produce(m kafka.Message) error {
func (k *mockProducer) Produce(_ kafka.Message) error {
return nil
}

func (k *mockProducer) ProduceBatch(messages []kafka.Message) error {
func (k *mockProducer) ProduceBatch(_ []kafka.Message) error {
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/kafka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ type ProducerConfig struct {
type SkipMessageByHeaderFn func(headers []Header) bool

func (c *Config) SetDefaults() {
if c.Logger == nil {
c.Logger = logger.New(c.LogLevel)
}
if c.Consumer.MaxRetry == 0 {
c.Consumer.MaxRetry = 3
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kafka/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func TestConfig_SetDefaults(t *testing.T) {
if !reflect.DeepEqual(tt.expected.Producer, k.Producer) {
t.Errorf("Expected: %+v, Actual: %+v", tt.expected.Producer, k.Producer)
}
if !reflect.DeepEqual(tt.expected.Logger, k.Logger) {
t.Errorf("Expected: %+v, Actual: %+v", tt.expected.Logger, k.Logger)
if k.Logger == nil {
t.Errorf("Expected Logger to be initialized, but got nil")
}
if !reflect.DeepEqual(tt.expected.LogLevel, k.LogLevel) {
t.Errorf("Expected: %+v, Actual: %+v", tt.expected.LogLevel, k.LogLevel)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module integration-test-example

go 1.19
go 1.24

replace github.com/Trendyol/kafka-consumer => ../..

Expand Down