Skip to content

Conversation

@paulozenida
Copy link

This MR, which pretty much adds contexts to all exported methods, allows us to use that information not only in the main library component but also in custom server list, which then can be used for other stuff such as instrumentation for new relic, which was the original objective for which I forked the library.

// Check if the context is expired.
select {
default:
case <-ctx.Done():
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a bit useless. At this point there is no network call yet. Dial happens below in c.dial. You want to extend dial with custom dialer, see https://pkg.go.dev/net#Dialer.DialContext

// should be shared onto.
PickServer(key string) (net.Addr, error)
Each(func(net.Addr) error) error
PickServer(ctx context.Context, key string) (net.Addr, error)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This is breaking change. I doubt it can be accepted.
  2. Wonder what is the use case to add context for these methods. You can have background goroutine which updates servers list if needed. Current implementation also indicates that context is not needed.

@dormando
Copy link
Collaborator

dormando commented Apr 4, 2025

Note: #126 as well

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants