Documentation ¶
Index ¶
- Constants
- func BindAndDial(network, localAddr, remoteAddr string, timeout time.Duration) (net.Conn, error)
- func CreateTapDevice() (*os.File, string, error)
- func GetBridgeVlanId(bridgeIf string) (int, error)
- func ListBridgePorts(bridge string) ([]string, error)
- func ListBridges() ([]net.Interface, error)
- func ListBroadcastInterfaces(interfaceType uint, logger log.DebugLogger) ([]net.Interface, map[string]net.Interface, error)
- func ListenWithReuse(network, address string) (net.Listener, error)
- func TestCarrier(name string) bool
- type CpuSharer
- type Dialer
- type MeasuringConnection
- type MeasuringDialer
- type TCPConn
Constants ¶
const ( InterfaceTypeBonding = 1 << iota InterfaceTypeBridge InterfaceTypeEtherNet InterfaceTypeVlan InterfaceTypeTunTap )
const SO_REUSEPORT = 15
Variables ¶
This section is empty.
Functions ¶
func BindAndDial ¶
BindAndDial is similar to the net.Dial function from the standard library except it binds the underlying network socket to a specified local address. This gives control over the local port number of the connection, rather than a randomly assigned port number.
func CreateTapDevice ¶
CreateTapDevice will create a "tap" network device with a randomly chosen interface name. The tap device file and the interface name are returned on success, else an error is returned. The device will be destroyed when the file is closed.
func GetBridgeVlanId ¶
GetBridgeVlanId will get the VLAN Id associated with the uplink EtherNet interface for the specified bridge interface. If there is no uplink then the returned VLAN Id will be -1.
func ListBridgePorts ¶
ListBridgePorts will return a list of names of interfaces plugged into the specified bridge interface. An error is returned if the specified interface does not exist or is not a bridge.
func ListBridges ¶
ListBridges will return a list of EtherNet (layer 2) bridges.
func ListBroadcastInterfaces ¶
func ListBroadcastInterfaces(interfaceType uint, logger log.DebugLogger) ( []net.Interface, map[string]net.Interface, error)
ListBroadcastInterfaces will return a list of broadcast (EtherNet, bridge, vlan) interfaces. Debugging progress messages are logged to logger.
func ListenWithReuse ¶
ListenWithReuse is similar to the net.Listen function from the standard library but sets the SO_REUSEADDR and SO_REUSEPORT options on the underlying socket. This is needed if using BindAndDial to specify the same local address as with the listener.
func TestCarrier ¶
TestCarrier will return true if the interface has a carrier signal.
Types ¶
type CpuSharer ¶
type CpuSharer interface {}
CpuSharer defines the interface for types which can be used to co-operatively share CPUs.
type Dialer ¶
Dialer defines a dialer that can be use to create connections.
func NewCpuSharingDialer ¶
NewCpuSharingDialer wraps dialer and returns a new Dialer which uses the cpuSharer to limit concurrent CPU usage. Whenever a blocking operation is about to commence (such a Dial or Read or Write for the connection) the cpuSharer.ReleaseCpu method is called, allowing the blocking operation to run concurrently. When the blocking operation completes, the cpuSharer.GrabCpu method is called, limiting the number of running goroutines that have to compete for the CPU. This helps avoid the thundering herd problem where large numbers of goroutines processing network transactions overwhelm the CPU and affect the responsiveness of other goroutines such as dashboards and health checks.
type MeasuringConnection ¶
MeasuringConnection implements the net.Conn interface. Additionally it has methods to return the cumulative time spent blocking in the Read or Write methods.
func (*MeasuringConnection) CumulativeReadTime ¶
func (conn *MeasuringConnection) CumulativeReadTime() time.Duration
CumulativeReadTime returns the cumulative time spent blocking on Read.
func (*MeasuringConnection) CumulativeWriteTime ¶
func (conn *MeasuringConnection) CumulativeWriteTime() time.Duration
CumulativeReadTime returns the cumulative time spent blocking on Write.
type MeasuringDialer ¶
type MeasuringDialer struct {
// contains filtered or unexported fields
}
MeasuringDialer implements the Dialer interface. Additionally it has methods to return the cumulative time spent blocking in the Dial method.
func NewMeasuringDialer ¶
func NewMeasuringDialer(dialer Dialer) *MeasuringDialer
NewMeasuringDialer wraps dialer and returns a dialer that can be used to measure the time spent in blocking operations.
func (*MeasuringDialer) CumulativeDialTime ¶
func (d *MeasuringDialer) CumulativeDialTime() time.Duration
CumulativeDialTime returns the cumulative time spent blocking on Dial.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package rrdialer implements a dialer which provides improved behaviour for hostnames with multiple IP addresses (aka.
|
Package rrdialer implements a dialer which provides improved behaviour for hostnames with multiple IP addresses (aka. |
terminal
|
|