From 1805a53fb49b27a745e855061b1ad9acc9afde47 Mon Sep 17 00:00:00 2001 From: mhmtszr Date: Tue, 28 May 2024 15:25:04 +0300 Subject: [PATCH] feat: Update README.md and add tests --- README.md | 1 + message_test.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 6041a60..fda7072 100644 --- a/README.md +++ b/README.md @@ -256,6 +256,7 @@ under [the specified folder](examples/with-sasl-plaintext) and then start the ap | `retryConfiguration.sasl.password` | SCRAM OR PLAIN password | | | `retryConfiguration.skipMessageByHeaderFn` | Function to filter messages based on headers, return true if you want to skip the message | nil | | `batchConfiguration.messageGroupLimit` | Maximum number of messages in a batch | | +| `batchConfiguration.messageGroupByteSizeLimit` | Maximum number of bytes in a batch | | | `batchConfiguration.batchConsumeFn` | Kafka batch consumer function, if retry enabled it, is also used to consume retriable messages | | | `batchConfiguration.preBatchFn` | This function enable for transforming messages before batch consuming starts | | | `batchConfiguration.balancer` | [see doc](https://pkg.go.dev/github.com/segmentio/kafka-go#Balancer) | leastBytes | diff --git a/message_test.go b/message_test.go index 03e5012..b9dcd3f 100644 --- a/message_test.go +++ b/message_test.go @@ -98,6 +98,25 @@ func TestMessage_AddHeader(t *testing.T) { }) } +func TestMessage_Size(t *testing.T) { + // Given + m := Message{ + Headers: []kafka.Header{ + {Key: "foo", Value: []byte("fooValue")}, + }, + Value: []byte("barValue"), + Key: []byte("bar"), + } + + // When + s := m.TotalSize() + + // Then + if s != 46 { + t.Fatalf("Total message size must be equal to 46") + } +} + func TestMessage_RemoveHeader(t *testing.T) { // Given m := Message{