Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Addr ¶
Addr represents a network end point address.
func (Addr) IPAddr ¶
IPAddr returns the string form of the IP address ip. It returns one of 4 forms:
- "<nil>", if ip has length 0
- dotted decimal ("192.0.2.1"), if ip is an IPv4 or IP4-mapped IPv6 address
- IPv6 ("2001:db8::1"), if ip is a valid IPv6 address
- the hexadecimal form of ip, without punctuation, if no other cases appl
func (Addr) IsLoopback ¶
IsLoopback reports whether ip is a loopback address.
type AggregatedListener ¶
type AggregatedListener interface { net.Listener // Addrs returns all listeners' network addresses. Addrs() []net.Addr // TCPAddrs returns all tcp listeners' network addresses. TCPAddrs() []*net.TCPAddr // UnixAddrs returns all unix listeners' network addresses. UnixAddrs() []*net.UnixAddr // AcceptTCP accepts the next tcp incoming call and returns the new // tcp connection. AcceptTCP() (*net.TCPConn, error) // AcceptUnix accepts the next unix incoming call and returns the new // unix connection. AcceptUnix() (*net.UnixConn, error) }
AggregatedListener is a listener aggregated by other listeners in order to satisfy net.Listener interface.
It makes http server can accept connections from several listeners in the meanwhile.
func NewAggregatedListener ¶
func NewAggregatedListener(listeners ...net.Listener) (AggregatedListener, error)
NewAggregatedListener aggregate all input listeners into one to satisfy net.Listener interface.
Must supply at least two listeners.
It takes the first listener as major to expose the address and accepts all listeners on background to get network connections.
type BalancedDialer ¶
type BalancedDialer interface { // DialContext connects to the address on the named network with // client side load balance. // // Balanceable networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only), // "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), other networks will not be // balanced. DialContext(ctx context.Context, network, address string) (net.Conn, error) }
BalancedDialer
func NewBalancedDialer ¶
func NewBalancedDialer(opt Options) BalancedDialer
type Balancer ¶
Balancer resort the addresses coming from resolver and put the first priority address to the head
type BalancerBuilder ¶
BalancerBuilder build a new balancer instance
type Interface ¶
Interface represents the local network interface
func InterfaceByName ¶
InterfaceByName returns the local network interface specified by name.
func (*Interface) Addrs ¶
Addrs returns a list of unicast interface addresses for a specific interface.
func (*Interface) IsLoopback ¶
IsLoopback returns true if the net interface is lookback
type InterfaceSlice ¶
type InterfaceSlice []Interface
InterfaceSlice reprecents a list of net interfaces
func Interfaces ¶
func Interfaces() (InterfaceSlice, error)
Interfaces returns a slice containing the local network interfaces
func InterfacesByIP ¶
func InterfacesByIP(ip string) (InterfaceSlice, error)
InterfacesByIP returns the local network interfaces that is using the specified IP address.
func InterfacesByLoopback ¶
func InterfacesByLoopback() (InterfaceSlice, error)
InterfacesByLoopback returns a list of loopback network interfaces.
func (InterfaceSlice) Contains ¶
func (ifaces InterfaceSlice) Contains(name string) bool
Contains checks if the net interface is in the collection
func (InterfaceSlice) Filter ¶
func (ifaces InterfaceSlice) Filter(filterFunc func(iface Interface) bool) InterfaceSlice
Filter filters some interfaces by filsterFunc if it returns true
func (InterfaceSlice) Get ¶
func (ifaces InterfaceSlice) Get(name string) *Interface
Get returns net interface device if it exists in the collection
func (InterfaceSlice) One ¶
func (ifaces InterfaceSlice) One() *Interface
One returns the first net interface in the list It returns nil if there is no element in the slice
type Options ¶
type Options struct { // BalancerBuilder build a client side load balancer BalancerBuilder BalancerBuilder // custom resolver, If not set, net.DefaultResolver will be used Resolver Resolver // contains filtered or unexported fields }
type Resolver ¶
type Resolver interface { LookupIPAddr(ctx context.Context, host string) (addrs []net.IPAddr, err error) LookupPort(ctx context.Context, network, service string) (port int, err error) }
A Resolver looks up names and numbers. It is an interface that represents net.Resolver