dnspool

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2018 License: BSD-2-Clause Imports: 3 Imported by: 3

README

Package dnspool creates a goroutine pool for DNS query to limit the number of OS threads that will be spawned by the go runtime.

Use godoc to see more details.

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

func Dial(netw, addr string) (c net.Conn, err error)

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 DialTimeout(netw, addr string, cTimeout time.Duration) (c net.Conn, err error)

func LookupHost

func LookupHost(host string) (addrs []string, err error)

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

func (*Resolver) LookupHost

func (r *Resolver) LookupHost(host string) (addrs []string, err error)

LookupHost has the same usage as net.LookupHost. Not thread safe.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL