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

Add new function for creation a connection DialKDBContext. #27

Closed
wants to merge 4 commits into from

Conversation

lkramer
Copy link

@lkramer lkramer commented Aug 8, 2019

I had an issue that when KDB went into debug trap mode it would allow establishing a TCP connection, but would not reply to handshake requests, causing the client to hang.

This new function allows to use a context specific timeout which forces a return even if the actual request hangs.

It will also close the connection, which should cause the handshake to fail so there will be no hanging go routine.

I thought about updating DialKDBTimeout with a similar functionality, but held off in case the existing behaviour was intentional. I can make the change if needed.

@sv
Copy link
Owner

sv commented Aug 17, 2019

Could you base your change on v1beta? it changes Dial api, so i would prefer to make changes like this in that branch

kdb.go Outdated
@@ -208,3 +209,37 @@ func DialKDBTimeout(host string, port int, auth string, timeout time.Duration) (
kdbconn := KDBConn{c, bufio.NewReader(c), host, fmt.Sprint(port), auth}
return &kdbconn, nil
}

// DialKDBContext connects to host:port using supplied user:password. It uses the context's build-in timeout.
func DialKDBContext(ctx context.Context, host string, port int, auth string) (*KDBConn, error) {
Copy link
Owner

Choose a reason for hiding this comment

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

if based on v1beta, also rename to DialContext to follow net.Dialer interface

@lkramer
Copy link
Author

lkramer commented Aug 28, 2019

Tracking in #28 instead.

@lkramer lkramer closed this Aug 28, 2019
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.

2 participants