소스 검색

Merge pull request #182 from Shopify/drain-successes

prod: drain successes on close just like errors
Willem van Bergen 11 년 전
부모
커밋
7436e99091
1개의 변경된 파일9개의 추가작업 그리고 2개의 파일을 삭제
  1. 9 2
      producer.go

+ 9 - 2
producer.go

@@ -208,9 +208,16 @@ func (p *Producer) Input() chan<- *MessageToSend {
 // it may otherwise leak memory. You must call this before calling Close on the
 // underlying client.
 func (p *Producer) Close() error {
-	go func() {
+	go withRecover(func() {
 		p.input <- &MessageToSend{flags: shutdown}
-	}()
+	})
+
+	if p.config.AckSuccesses {
+		go withRecover(func() {
+			for _ = range p.successes {
+			}
+		})
+	}
 
 	var errors ProduceErrors
 	for event := range p.errors {