From f1b923e4d49b9fed87f0c1616610cb38e8c7955e Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Sat, 3 Jun 2023 07:50:25 -0600 Subject: [PATCH] kgo: add DialTLS option Opts into TLS without requiring a tls.Config --- pkg/kgo/client.go | 2 ++ pkg/kgo/config.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/pkg/kgo/client.go b/pkg/kgo/client.go index b421932b..78edc6d9 100644 --- a/pkg/kgo/client.go +++ b/pkg/kgo/client.go @@ -248,6 +248,8 @@ func (cl *Client) OptValues(opt any) []any { return []any{cfg.dialFn} case namefn(DialTLSConfig): return []any{cfg.dialTLS} + case namefn(DialTLS): + return []any{cfg.dialTLS != nil} case namefn(SeedBrokers): return []any{cfg.seedBrokers} case namefn(MaxVersions): diff --git a/pkg/kgo/config.go b/pkg/kgo/config.go index 7c40f1bd..c1732b95 100644 --- a/pkg/kgo/config.go +++ b/pkg/kgo/config.go @@ -642,6 +642,12 @@ func DialTLSConfig(c *tls.Config) Opt { return clientOpt{func(cfg *cfg) { cfg.dialTLS = c }} } +// DialTLS opts into dialing brokers with TLS. This is a shortcut for +// DialTLSConfig with an empty config. See DialTLSConfig for more details. +func DialTLS() Opt { + return DialTLSConfig(new(tls.Config)) +} + // SeedBrokers sets the seed brokers for the client to use, overriding the // default 127.0.0.1:9092. //