소스 검색

Only mention closing the Client on the FromClient constructors

Evan Huus 10 년 전
부모
커밋
6be486f900
3개의 변경된 파일8개의 추가작업 그리고 6개의 파일을 삭제
  1. 3 3
      async_producer.go
  2. 2 1
      consumer.go
  3. 3 2
      sync_producer.go

+ 3 - 3
async_producer.go

@@ -17,8 +17,7 @@ func forceFlushThreshold() int {
 // and parses responses for errors. You must read from the Errors() channel or the
 // producer will deadlock. You must call Close() or AsyncClose() on a producer to avoid
 // leaks: it will not be garbage-collected automatically when it passes out of
-// scope (this is in addition to calling Close on the underlying client, which
-// is still necessary).
+// scope.
 type AsyncProducer interface {
 
 	// AsyncClose triggers a shutdown of the producer, flushing any messages it may have
@@ -74,7 +73,8 @@ func NewAsyncProducer(addrs []string, conf *Config) (AsyncProducer, error) {
 	return p, nil
 }
 
-// NewAsyncProducerFromClient creates a new Producer using the given client.
+// NewAsyncProducerFromClient creates a new Producer using the given client. It is still
+// necessary to call Close() on the underlying client when shutting down this producer.
 func NewAsyncProducerFromClient(client Client) (AsyncProducer, error) {
 	// Check that we are not dealing with a closed Client before processing any other arguments
 	if client.Closed() {

+ 2 - 1
consumer.go

@@ -73,7 +73,8 @@ func NewConsumer(addrs []string, config *Config) (Consumer, error) {
 	return c, nil
 }
 
-// NewConsumerFromClient creates a new consumer using the given client.
+// NewConsumerFromClient creates a new consumer using the given client. It is still
+// necessary to call Close() on the underlying client when shutting down this consumer.
 func NewConsumerFromClient(client Client) (Consumer, error) {
 	// Check that we are not dealing with a closed Client before processing any other arguments
 	if client.Closed() {

+ 3 - 2
sync_producer.go

@@ -4,7 +4,7 @@ import "sync"
 
 // SyncProducer publishes Kafka messages. It routes messages to the correct broker, refreshing metadata as appropriate,
 // and parses responses for errors. You must call Close() on a producer to avoid leaks, it may not be garbage-collected automatically when
-// it passes out of scope (this is in addition to calling Close on the underlying client, which is still necessary).
+// it passes out of scope.
 type SyncProducer interface {
 
 	// SendMessage produces a given message, and returns only when it either has succeeded or failed to produce.
@@ -32,7 +32,8 @@ func NewSyncProducer(addrs []string, config *Config) (SyncProducer, error) {
 	return newSyncProducerFromAsyncProducer(p.(*asyncProducer)), nil
 }
 
-// NewSyncProducerFromClient creates a new SyncProducer using the given client.
+// NewSyncProducerFromClient creates a new SyncProducer using the given client. It is still
+// necessary to call Close() on the underlying client when shutting down this producer.
 func NewSyncProducerFromClient(client Client) (SyncProducer, error) {
 	p, err := NewAsyncProducerFromClient(client)
 	if err != nil {