net

package
v3.0.20 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: AGPL-3.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputePerfStats

func ComputePerfStats(latencies, throughputs []float64) (madmin.NetLatency, madmin.NetThroughput, error)

ComputePerfStats takes arrays of Latency & Throughput to compute Statistics

func IsConnRefusedErr

func IsConnRefusedErr(err error) bool

IsConnRefusedErr - Checks for "connection refused" errors.

func IsConnResetErr

func IsConnResetErr(err error) bool

IsConnResetErr - Checks for "connection reset" errors.

func IsNetworkOrHostDown

func IsNetworkOrHostDown(err error, expectTimeouts bool) bool

IsNetworkOrHostDown - if there was a network error or if the host is down. expectTimeouts indicates that *context* timeouts are expected and does not indicate a downed host. Other timeouts still returns down.

Types

type Host

type Host struct {
	Name      string
	Port      Port
	IsPortSet bool
}

Host - holds network host IP/name and its port.

func ParseHost

func ParseHost(s string) (*Host, error)

ParseHost - parses string into Host

func (Host) Equal

func (host Host) Equal(compHost Host) bool

Equal - checks whether given host is equal or not.

func (Host) IsEmpty

func (host Host) IsEmpty() bool

IsEmpty - returns whether Host is empty or not

func (Host) MarshalJSON

func (host Host) MarshalJSON() ([]byte, error)

MarshalJSON - converts Host into JSON data

func (Host) String

func (host Host) String() string

String - returns string representation of Host.

func (*Host) UnmarshalJSON

func (host *Host) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON - parses data into Host.

type Port

type Port uint16

Port - network port

func GetFreePort

func GetFreePort() (Port, error)

GetFreePort asks the kernel for a free open port that is ready to use.

func ParsePort

func ParsePort(s string) (p Port, err error)

ParsePort - parses string into Port

func (Port) String

func (p Port) String() string

String - returns string representation of port.

type TCPConfig added in v3.0.17

type TCPConfig struct {
	// UserTimeout is the maximum amount of time that transmitted
	// data may remain unacknowledged before forcefully closing the
	// connection.
	//
	// Moreover, when used with TCP keepalives, UserTimeout
	// overrides keepalive to determine when to close a connection
	// due to keepalive failure.
	//
	// If empty, no TCP user timeout is set.
	UserTimeout time.Duration

	// SendBufSize sets a custom send buffer size on the TCP socket if
	// not zero.
	SendBufSize int

	// RecvBufSize, sets a custom receive buffer size on the TCP socket if
	// not zero.
	RecvBufSize int

	// If true, sets TCP_NODELAY on the network connection which
	// disables Nagle's algorithm such that small packages are not
	// combined into larger ones but sent right away.
	NoDelay bool

	// If non-empty, create a TCP socket on the given virtual routing
	// and forwarding (VRF) interface.
	Interface string

	// Trace is a callback for debug logging
	Trace func(string)
}

A TCPConfig structure is used to configure a TCP client or server connections.

func (*TCPConfig) Clone added in v3.0.17

func (c *TCPConfig) Clone() *TCPConfig

Clone returns a copy of a TCPConfig structure.

func (*TCPConfig) Control added in v3.0.17

func (c *TCPConfig) Control(network, address string, rc syscall.RawConn) error

Control applies the TCPConfig to a raw network connection before dialing.

Network and address parameters passed to Control function are not necessarily the ones passed to Dial. For example, passing "tcp" to Dial will cause the Control function to be called with "tcp4" or "tcp6".

type URL

type URL url.URL

URL - improved JSON friendly url.URL.

func ParseHTTPURL

func ParseHTTPURL(s string) (u *URL, err error)

ParseHTTPURL - parses a string into HTTP URL, string is expected to be of form http:// or https://

func ParseURL

func ParseURL(s string) (u *URL, err error)

ParseURL - parses string into URL.

func (URL) Hostname

func (u URL) Hostname() string

Hostname returns u.Host, stripping any valid port number if present

If the result is enclosed in square brackets, as literal IPv6 addresses are, the square brackets are removed from the result.

func (URL) IsEmpty

func (u URL) IsEmpty() bool

IsEmpty - checks URL is empty or not.

func (URL) MarshalJSON

func (u URL) MarshalJSON() ([]byte, error)

MarshalJSON - converts to JSON string data.

func (URL) Port

func (u URL) Port() string

Port returns the port part of u.Host, without the leading colon.

If u.Host doesn't contain a valid numeric port, Port returns an empty string.

func (URL) String

func (u URL) String() string

String - returns string representation of URL.

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON - parses given data into URL.

Jump to

Keyboard shortcuts

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