Repository navigation
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.ErrMessageUnmarshalandconsumer.ErrMessageHandleare removed. They were never returned by the library, so code that matched them witherrors.Isnever matched anything; delete those references.- The metric
kafka_consumer_committed_total(counter) is replaced bykafka_consumer_committed_offset(gauge bytopic,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 withmax by (topic, partition). HandlerBatchflushes afterBatchFlushTimeout(WithHandlerBatchFlushTimeout) with no new messages instead of on a fixed tick.Group.Runwaits 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.WithSASLOAuthandsasl.TokenProvider/sasl.AccessToken: SASL/OAUTHBEARER authentication. -
producer.WithErrorHandlerandproducer.SendError: delivery errors ofSendreach 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.NewHandlerBatchdoes the same for batch handlers. It lives in a separate package socodec/proto/wirestays a pure codec without the Kafka dependencies.
Changed
Producer.Closewaits for theSendandSendSynccalls in progress and flushes the queued messages; their delivery errors reach the error handler beforeClosereturns.- Messages skipped by
HandlerBatchadvance 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
consumer98.4%,producer95.2%,wire95.2%), benchmarks (make bench, numbers in the README), package docs. docker-compose.ymland CI run Kafka 4.4.0; golangci-lint v2; the CI push trigger runs onmainagain.
Full Changelog: v1.0.3...v1.1.0