namespaces

package
v0.108.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapIfFail

func WrapIfFail(msg string, originalerr error, fn func() error) error

WrapIfFail executes the provided function. If the function succeeds it simply returns the original error (that can be nil). If the function fails then it assesses if an original error was provided and wraps it if true. This function is a sugar to be used at when deferring function that can also return errors, we don't want to loose any context.

Types

type Configuration

type Configuration struct {
	// Logf is a function that will be used to log messages. If not
	// provided the default logger will be used.
	Logf func(string, ...interface{})
	// Port is the port to use for the UDP and TCP pings.
	Port int
	// Timeout is the timeout for the UDP and TCP connection to finish.
	Timeout time.Duration
}

Configuration holds the runtime configuration for this package.

func NewConfiguration

func NewConfiguration(options ...Option) Configuration

NewConfiguration creates a new configuration with the provided options.

type NamespacePinger

type NamespacePinger struct {
	InternalIP net.IP
	ExternalIP net.IP
}

func NewNamespacePinger

func NewNamespacePinger(_, _ string, _ ...Option) (*NamespacePinger, error)

func (*NamespacePinger) Close

func (n *NamespacePinger) Close() error

func (*NamespacePinger) PingTCP

func (n *NamespacePinger) PingTCP(_ net.IP) error

func (*NamespacePinger) PingUDP

func (n *NamespacePinger) PingUDP(_ net.IP) error

func (*NamespacePinger) StartTCPEchoServer

func (n *NamespacePinger) StartTCPEchoServer(errors chan error)

func (*NamespacePinger) StartUDPEchoServer

func (n *NamespacePinger) StartUDPEchoServer(errors chan error)

type Option

type Option func(*Configuration)

Option is a function that sets an optional configuration.

func WithLogf

func WithLogf(f func(string, ...interface{})) Option

WithLogf sets the log function for this package.

func WithPort

func WithPort(port int) Option

WithPort sets the port to use for the UDP and TCP pings.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the timeout for the UDP and TCP connections.

Jump to

Keyboard shortcuts

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