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 a IP addr in this error for locating issues faster? #732

Open
goith opened this issue Jan 19, 2020 · 4 comments
Open

add a IP addr in this error for locating issues faster? #732

goith opened this issue Jan 19, 2020 · 4 comments

Comments

@goith
Copy link

goith commented Jan 19, 2020

var ErrDialTimeout = errors.New("dialing to the given TCP address timed out")

usually, dialing a host, that resovle to mullti ips. and If include the IP information in this ErrDialTimeout, we can know which server is the problem faster.

@goith goith changed the title add a dst IP in this error for locating issues faster? add a IP addr in this error for locating issues faster? Jan 19, 2020
@erikdubbelboer
Copy link
Collaborator

The problem is that we can't really add it to the error as that would change the API. If we make the error dynamic doing err == fasthttp.ErrDialTimeout won't work anymore.

Anyone have any suggestions on how to put this in there?

@phuslu
Copy link
Contributor

phuslu commented Mar 11, 2020

a possible path is

  1. rewrite fasthttp.ErrDialTimeout to a struct, maybe DailTimeoutError which implement net.Error interface
// see https://golang.org/src/net/net.go?s=17034:17068#L539
type DailTimeoutError struct {
	Err  string
	Addr string
}

func (e *DailTimeoutError) Error() string {
	if e == nil {
		return "<nil>"
	}
	s := e.Err
	if e.Addr != "" {
		s = "dialing to the given TCP address " + e.Addr + ": " + s
	}
	return s
}

func (e *DailTimeoutError) Timeout() bool   { return true}
func (e *DailTimeoutError) Temporary() bool { return true}

var ErrDialTimeout = &DailTimeoutError{Err: "dialing to the given TCP address timed out"}
  1. return "Timeout() bool" to true
  2. encourage user use Timeout() bool or net.Error interface
  3. finally, drop ErrDialTimeout at proper future.

@erikdubbelboer
Copy link
Collaborator

@phuslu that would still break for users who currently do err == fasthttp.ErrDialTimeout in their code.

@Fenny
Copy link
Contributor

Fenny commented Aug 16, 2020

This would break the existing API design, but could be possible when Fasthttp moves to an organization github.com/fasthttp/fasthttp #684

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

4 participants