Documentation
¶
Overview ¶
Package dnspool creates a goroutine pool for DNS query to limit the number of OS threads that will be spawned by the go runtime.
Default number of goroutines for DNS lookup is set to 8 now. You can increase goroutine number by calling SetGoroutineNumber. Note the maximum number of goroutines is 32. (Please tell me if this number is not enough.)
This package will no longer be needed when the go runtime provides a way to limit OS threads creation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dial ¶
Dial has the same usage as as net.Dial. This function will use LookupHost to resolve host address, then try net.Dial on each returned ip address till one succeeds or all fail.
func DialTimeout ¶
func LookupHost ¶
LookupHost has the same usage as net.LookupHost. If you are going to call this repeatedly in the same goroutine, it's better to create a new Resolver to avoid some performance overhead.
func SetGoroutineNumber ¶
func SetGoroutineNumber(n int)
SetGoroutineNumber sets the number of goroutines used to do DNS query. If n <= current goroutine number or is larger than maximum concurrent DNS request, this function will do nothing.
Types ¶
type Resolver ¶
type Resolver lookupRequest
Resolver provides LookupHost method which can be used non-concurrently.
func NewResolver ¶
func NewResolver() *Resolver