Skip to content

Commit

Permalink
Remove TODO. (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored May 8, 2024
1 parent e15f411 commit 30e1877
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
26 changes: 2 additions & 24 deletions lib/kafkalib/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,15 @@ package kafkalib

import (
"errors"
"log/slog"
"strings"

"github.com/segmentio/kafka-go"
)

func isExceedMaxMessageBytesErr(err error) bool {
if err == nil {
return false
}

if errors.Is(err, kafka.MessageSizeTooLarge) {
return true
}

if strings.Contains(err.Error(),
"Message Size Too Large: the server has a configurable maximum message size to avoid unbounded memory allocation and the client attempted to produce a message larger than this maximum") {
// TODO: Remove this if we don't see it in the logs
slog.Error("Matched 'Message Size Too Large' error but not kafka.MessageSizeTooLarge")
return true
}

return false
return err != nil && errors.Is(err, kafka.MessageSizeTooLarge)
}

// isRetryableError - returns true if the error is retryable
// If it's retryable, you need to reload the Kafka client.
func isRetryableError(err error) bool {
if err == nil {
return false
}

return errors.Is(err, kafka.TopicAuthorizationFailed)
return err != nil && errors.Is(err, kafka.TopicAuthorizationFailed)
}
4 changes: 0 additions & 4 deletions lib/kafkalib/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ func TestIsExceedMaxMessageBytesErr(t *testing.T) {
{
err: nil,
},
{
err: fmt.Errorf("Message Size Too Large: the server has a configurable maximum message size to avoid unbounded memory allocation and the client attempted to produce a message larger than this maximum, bytes: 1223213213"),
expected: true,
},
{
err: kafka.TopicAuthorizationFailed,
expected: false,
Expand Down

0 comments on commit 30e1877

Please sign in to comment.