Use context-aware wait in Kafka sender retry loop#187
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis pull request modifies Kafka writer error handling by replacing a hardcoded 100ms sleep with a context-aware wait helper function. The change enables the retry logic to respond to context cancellation events by propagating context errors, whilst maintaining the existing retry-once behaviour. Corresponding test coverage is added with four new test cases that exercise the wait helper with zero duration, context cancellation, normal duration completion, and Send() method cancellation scenarios. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|



Problem
Kafka sender retry uses
time.Sleep(100ms)which ignores context cancellation. During shutdown, the goroutine blocks for the full sleep duration.Why
Shutdown signals are delayed — in a tight retry loop this adds unnecessary latency to graceful shutdown.
Fix
Replace
time.Sleepwith context-awarewait()that returns immediately on cancellation.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests