From 0db53a78de877f84627808e6c15d6650d9b6bc78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20=C3=96nal?= <81802983+nemre@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:12:29 +0300 Subject: [PATCH 1/5] chore: add actions support for depandabot (#41) --- .github/dependabot.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8534f71..ff86c0d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,12 @@ version: 2 updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + open-pull-requests-limit: 10 - package-ecosystem: gomod directory: "/" schedule: interval: daily - open-pull-requests-limit: 10 \ No newline at end of file + open-pull-requests-limit: 10 From ddb99fbc0f23cb62be0aa2cb68b4ee40e1fbfee7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:38:59 +0300 Subject: [PATCH 2/5] chore(deps): bump actions/setup-go from 3 to 4 (#42) Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/integration-test.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 6f9e429..82688f5 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -16,7 +16,7 @@ jobs: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: 1.19 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 403a2e8..228ac6c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: - 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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9471879..7942a4d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: 1.19 From b00ff7e5ee78c08162c419058c9523db12085aaf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:39:12 +0300 Subject: [PATCH 3/5] chore(deps): bump actions/checkout from 3 to 4 (#43) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/integration-test.yml | 6 +++--- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 82688f5..79e7060 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -20,11 +20,11 @@ jobs: with: go-version: 1.19 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Start containers run: docker compose -f test/integration/docker-compose.yml up --wait --build --force-recreate --remove-orphans - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Integration Test run: go test -v test/integration/integration_test.go env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 228ac6c..91f8267 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7942a4d..c9a2b56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 From 624bf791599e6be81b44f1dec91b58b0744c2c2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:39:59 +0300 Subject: [PATCH 4/5] chore(deps): bump goreleaser/goreleaser-action from 4 to 5 (#44) Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 4 to 5. - [Release notes](https://github.com/goreleaser/goreleaser-action/releases) - [Commits](https://github.com/goreleaser/goreleaser-action/compare/v4...v5) --- updated-dependencies: - dependency-name: goreleaser/goreleaser-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 91f8267..b4a14fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: go-version: 1.19 - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v5 with: version: latest args: release --rm-dist From 05ec5214889993039b14467f8a5d7f8a481dcb17 Mon Sep 17 00:00:00 2001 From: BurakG01 <40125013+BurakG01@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:23:38 +0300 Subject: [PATCH 5/5] docs: add deadletter topic example (#48) --- examples/docker-compose.yml | 1 + examples/with-deadletter/main.go | 66 ++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 examples/with-deadletter/main.go diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml index fac94a0..3b3ead7 100644 --- a/examples/docker-compose.yml +++ b/examples/docker-compose.yml @@ -41,6 +41,7 @@ services: cub kafka-ready -b kafka:9092 1 20 && \ kafka-topics --create --topic standart-topic --if-not-exists --zookeeper zookeeper:2181 --partitions 1 --replication-factor 1 && \ kafka-topics --create --topic retry-topic --if-not-exists --zookeeper zookeeper:2181 --partitions 1 --replication-factor 1 && \ + kafka-topics --create --topic error-topic --if-not-exists --zookeeper zookeeper:2181 --partitions 1 --replication-factor 1 && \ sleep infinity'" environment: KAFKA_BROKER_ID: ignored diff --git a/examples/with-deadletter/main.go b/examples/with-deadletter/main.go new file mode 100644 index 0000000..b11c361 --- /dev/null +++ b/examples/with-deadletter/main.go @@ -0,0 +1,66 @@ +package main + +import ( + "context" + "errors" + "fmt" + "github.com/Trendyol/kafka-konsumer" + "os" + "os/signal" + "time" +) + +const ( + topicName = "standart-topic" + retryTopicName = "retry-topic" + deadLetterTopicName = "error-topic" +) + +func main() { + producer, _ := kafka.NewProducer(kafka.ProducerConfig{ + Writer: kafka.WriterConfig{ + Brokers: []string{"localhost:29092"}, + }, + }) + + _ = producer.Produce(context.Background(), kafka.Message{ + Topic: topicName, + Key: []byte("1"), + Value: []byte(`{ "foo": "bar" }`), + }) + + consumerCfg := &kafka.ConsumerConfig{ + Concurrency: 1, + Reader: kafka.ReaderConfig{ + Brokers: []string{"localhost:29092"}, + Topic: topicName, + GroupID: "konsumer.group.test", + }, + RetryEnabled: true, + RetryConfiguration: kafka.RetryConfiguration{ + DeadLetterTopic: deadLetterTopicName, + Brokers: []string{"localhost:29092"}, + Topic: retryTopicName, + StartTimeCron: "*/1 * * * *", + WorkDuration: 50 * time.Second, + MaxRetry: 1, + }, + ConsumeFn: consumeFn, + } + + consumer, _ := kafka.NewConsumer(consumerCfg) + defer consumer.Stop() + + consumer.Consume() + + fmt.Println("Consumer started...!") + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt) + <-c +} + +func consumeFn(message kafka.Message) error { + fmt.Printf("Message From %s with value %s", message.Topic, string(message.Value)) + // returns error to be sent to dead-letter topic + return errors.New("consumer error") +}