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

[util][httputil] Unix domain socket #93

Closed
at15 opened this issue Sep 22, 2018 · 2 comments
Closed

[util][httputil] Unix domain socket #93

at15 opened this issue Sep 22, 2018 · 2 comments
Assignees
Milestone

Comments

@at15
Copy link
Member

at15 commented Sep 22, 2018

unix client

func NewPooledUnixTransport(sockFile string) *http.Transport {
	return &http.Transport{
		DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
			d := net.Dialer{
				Timeout:   30 * time.Second,
				KeepAlive: 30 * time.Second,
				DualStack: true,
			}
			return d.DialContext(ctx, "unix", sockFile)
		},
		MaxIdleConns:          100,
		IdleConnTimeout:       90 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
	}
}

unix server

func ListenAndServeUnix(srv *http.Server, addr string) error {
	ln, err := net.Listen("unix", addr)
	if err != nil {
		return err
	}
	// TODO: do we need tcpKeepAliveListener like the default tcp ListenAndServe?
	return srv.Serve(ln)
}
@at15 at15 added this to the 0.0.8 milestone Sep 22, 2018
@at15 at15 self-assigned this Sep 22, 2018
@at15 at15 changed the title [util][httputil] Pooled client, unix domain socket [util][httputil] Unix domain socket Sep 22, 2018
at15 added a commit that referenced this issue Sep 22, 2018
- get `{"message":"page not found"}`
@at15
Copy link
Member Author

at15 commented Nov 26, 2018

the test is causing race problem in go tip, not sure if the race detector has improved or something else

see https://travis-ci.org/dyweb/gommon/jobs/459629689

@at15
Copy link
Member Author

at15 commented Dec 9, 2018

fixed in #90

@at15 at15 closed this as completed Dec 9, 2018
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