Skip to content

Commit

Permalink
use TryProduce instead of blocking Produce if buffer is full
Browse files Browse the repository at this point in the history
  • Loading branch information
weeco committed Apr 5, 2024
1 parent 2bc1ad7 commit 2d34cf1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions e2e/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (s *Service) produceMessage(ctx context.Context, partition int) {
pID := strconv.Itoa(partition)
s.messagesProducedInFlight.WithLabelValues(pID).Inc()
s.messageTracker.addToTracker(msg)
s.client.Produce(childCtx, record, func(r *kgo.Record, err error) {
s.client.TryProduce(childCtx, record, func(r *kgo.Record, err error) {
defer cancel()
ackDuration := time.Since(startTime)
s.messagesProducedInFlight.WithLabelValues(pID).Dec()
Expand All @@ -45,7 +45,7 @@ func (s *Service) produceMessage(ctx context.Context, partition int) {

if err != nil {
s.messagesProducedFailed.WithLabelValues(pID).Inc()
s.messageTracker.removeFromTracker(msg.MessageID)
_ = s.messageTracker.removeFromTracker(msg.MessageID)

s.logger.Info("failed to produce message to end-to-end topic",
zap.String("topic_name", r.Topic),
Expand Down

0 comments on commit 2d34cf1

Please sign in to comment.