Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go: http.Server connection pool

I know http.Client in Go language has connection pool in type Transport

But there is no Transport in http.Server

I wish to access server's pool.

  1. List all connections
  2. Close connections/remove them from pool

Update

I am learning Go source code https://code.google.com/p/go/source/browse/src/pkg/net/http/server.go#1087

It seems that this function has the answer that there is no Pool.

May be someone knows how to override that function? Do I have to create a hole copy of package?

like image 482
Max Avatar asked Oct 02 '22 18:10

Max


1 Answers

I got answer on go-nuts mailing list.

https://groups.google.com/forum/#!topic/golang-nuts/eoBsx0Sl3Co

  1. Transport is not available in server (only in client)
  2. I can pass my own net.Listener
  3. LimitListener is one of such implementations. https://code.google.com/p/go/source/browse/netutil/listen.go?repo=net
like image 121
Max Avatar answered Oct 07 '22 20:10

Max