Skip to content

v1.1.0

Latest

Choose a tag to compare

@korableg korableg released this 08 Nov 12:13
76f008a

TLS and SASL/OAUTHBEARER for producer and consumer, async delivery errors in the producer, the new protobus package, and a dependency update.

Breaking changes

  • Go 1.26 is the minimum version (was 1.23).
  • consumer.ErrMessageUnmarshal and consumer.ErrMessageHandle are removed. They were never returned by the library, so code that matched them with errors.Is never matched anything; delete those references.
  • The metric kafka_consumer_committed_total (counter) is replaced by kafka_consumer_committed_offset (gauge by topic, partition). Dashboards and alerts on the old name go silent. After a rebalance the previous owner keeps the last value of the partition, so query it with max by (topic, partition).
  • HandlerBatch flushes after BatchFlushTimeout (WithHandlerBatchFlushTimeout) with no new messages instead of on a fixed tick.
  • Group.Run waits with backoff (100ms → 10s) between failed consume sessions instead of retrying in a busy loop.

Added

  • producer.WithTLS, consumer.WithTLS: TLS connection to the brokers; a nil config means TLS 1.2+ with the system roots.

  • producer.WithSASLOAuth, consumer.WithSASLOAuth and sasl.TokenProvider / sasl.AccessToken: SASL/OAUTHBEARER authentication.

  • producer.WithErrorHandler and producer.SendError: delivery errors of Send reach the caller with the topic, key, ID, event type and source message.

  • codec.ErrNilMessage: the wire encoder rejects nil and typed-nil messages.

  • New package protobus: a consumer handler whose wire decoder is inferred from the handler function, so the event type is written once.

    -consumer.NewHandler(wire.Decoder[*events.X](),
    -    func(ctx context.Context, msg *events.X, raw consumer.Message) error { ... })
    +protobus.NewHandler(
    +    func(ctx context.Context, msg *events.X, raw consumer.Message) error { ... })

    protobus.NewHandlerBatch does the same for batch handlers. It lives in a separate package so codec/proto/wire stays a pure codec without the Kafka dependencies.

Changed

  • Producer.Close waits for the Send and SendSync calls in progress and flushes the queued messages; their delivery errors reach the error handler before Close returns.
  • Messages skipped by HandlerBatch advance the committed offsets.
  • Dependencies: sarama 1.45 → 1.61, backoff v4 → v7, prometheus client 1.21 → 1.25, protobuf 1.36.6 → 1.36.12.

Other

  • Unit tests with mocks for every package (coverage consumer 98.4%, producer 95.2%, wire 95.2%), benchmarks (make bench, numbers in the README), package docs.
  • docker-compose.yml and CI run Kafka 4.4.0; golangci-lint v2; the CI push trigger runs on main again.

Full Changelog: v1.0.3...v1.1.0