From 66ef49763cb7fe1a60d4d88384ba3d47c36e1ba5 Mon Sep 17 00:00:00 2001 From: Martin Schneppenheim Date: Tue, 6 Oct 2020 18:45:50 +0200 Subject: [PATCH 1/4] Enhance NewClient documentation --- pkg/kgo/client.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/kgo/client.go b/pkg/kgo/client.go index 90024b7c..9b504bb6 100644 --- a/pkg/kgo/client.go +++ b/pkg/kgo/client.go @@ -86,7 +86,12 @@ func stddial(ctx context.Context, addr string) (net.Conn, error) { } // NewClient returns a new Kafka client with the given options or an error if -// the options are invalid. +// the options are invalid. The connection is initiated lazily. Upon the first +// request sent to the broker the client will initiate a connection to +// Kafka (if needed). +// NewClient also launches a goroutine which periodically updates the cached +// topic metadata. It ensures that the cached metadata won't be older than +// MetadataMaxAge (5min by default). func NewClient(opts ...Opt) (*Client, error) { cfg := defaultCfg() for _, opt := range opts { From ea6fa741ea9f59d603773a5708496eee4db950cf Mon Sep 17 00:00:00 2001 From: Martin Schneppenheim Date: Tue, 6 Oct 2020 18:46:45 +0200 Subject: [PATCH 2/4] Grammar fix --- pkg/kgo/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kgo/client.go b/pkg/kgo/client.go index 9b504bb6..a03b39dd 100644 --- a/pkg/kgo/client.go +++ b/pkg/kgo/client.go @@ -87,7 +87,7 @@ func stddial(ctx context.Context, addr string) (net.Conn, error) { // NewClient returns a new Kafka client with the given options or an error if // the options are invalid. The connection is initiated lazily. Upon the first -// request sent to the broker the client will initiate a connection to +// request sent to a broker the client will initiate a connection to // Kafka (if needed). // NewClient also launches a goroutine which periodically updates the cached // topic metadata. It ensures that the cached metadata won't be older than From 52997a97d156511e031cbc51d96b629ee17a7eca Mon Sep 17 00:00:00 2001 From: Martin Schneppenheim Date: Tue, 6 Oct 2020 19:48:03 +0200 Subject: [PATCH 3/4] Reword comment Co-authored-by: Travis Bischel --- pkg/kgo/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/kgo/client.go b/pkg/kgo/client.go index a03b39dd..960ba3ae 100644 --- a/pkg/kgo/client.go +++ b/pkg/kgo/client.go @@ -86,9 +86,9 @@ func stddial(ctx context.Context, addr string) (net.Conn, error) { } // NewClient returns a new Kafka client with the given options or an error if -// the options are invalid. The connection is initiated lazily. Upon the first -// request sent to a broker the client will initiate a connection to -// Kafka (if needed). +// the options are invalid. Connections to brokers are lazily created only when +// requests are written to them. +// // NewClient also launches a goroutine which periodically updates the cached // topic metadata. It ensures that the cached metadata won't be older than // MetadataMaxAge (5min by default). From cdf6a66d40a447cc98f1b111f3dbf83951eda7ad Mon Sep 17 00:00:00 2001 From: Martin Schneppenheim Date: Tue, 6 Oct 2020 19:50:49 +0200 Subject: [PATCH 4/4] Remove detailed information about the metadata updater Co-authored-by: Travis Bischel --- pkg/kgo/client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/kgo/client.go b/pkg/kgo/client.go index 960ba3ae..8039aa6d 100644 --- a/pkg/kgo/client.go +++ b/pkg/kgo/client.go @@ -90,8 +90,7 @@ func stddial(ctx context.Context, addr string) (net.Conn, error) { // requests are written to them. // // NewClient also launches a goroutine which periodically updates the cached -// topic metadata. It ensures that the cached metadata won't be older than -// MetadataMaxAge (5min by default). +// topic metadata. func NewClient(opts ...Opt) (*Client, error) { cfg := defaultCfg() for _, opt := range opts {