Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting Dialer in a new Writer requires doing a Lookup wrapper #1326

Open
ake-persson opened this issue Sep 3, 2024 · 0 comments
Open

Setting Dialer in a new Writer requires doing a Lookup wrapper #1326

ake-persson opened this issue Sep 3, 2024 · 0 comments

Comments

@ake-persson
Copy link

ake-persson commented Sep 3, 2024

Describe the solution you would like

Defining a new writer should preferably have an option for setting dialer.

w := &kafka.Writer{Dialer: dialer, ...}

Alt. have a helper when defining Dial in Transport.

A clear and concise description of what you want to happen.

Currently you have to define a Dial function that handles Lookup in the Transport. This doesn't seem optimal.

tr := &kafka.Transport{dial: MyFunc(dialer), ...}

This is the current implementation in NewWriter().

dial := func(ctx context.Context, network, addr string) (net.Conn, error) {
		start := time.Now()
		defer func() {
			stats.dials.observe(1)
			stats.dialTime.observe(int64(time.Since(start)))
		}()
		address, err := lookupHost(ctx, addr, resolver)
		if err != nil {
			return nil, err
		}
		return dialer.DialContext(ctx, network, address)
	}

Supporting documentation

Please provides links to relevant Kafka protocol docs and/or KIPs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant