transport

package
v0.0.0-...-9d76940 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package transport provides a context wrapper and error handling around a UDP connection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transport

type Transport interface {

	// Address returns the IP:port of the remote device. This will always have
	// the port, even if the address provided was missing it (we default to
	// 623).
	Address() net.Addr

	// Send encapsulates the provided data in a UDP packet and sends it to the
	// BMC's address. It then blocks until a packet is received, and returns the
	// data it contains. If the context expires before all of this is performed,
	// or there is a network error, the returned slice will be nil and the error
	// will be returned.
	Send(context.Context, []byte) ([]byte, error)

	// Close cleanly shuts down the underlying connection, returning any error
	// that occurs. It is envisaged that this call is deferred as soon as the
	// transport is successfully created.
	Close() error
}

Transport defines an interface capable of sending and receiving data to and from a device. It logically represents a UDP socket and receive buffer. Unless specified otherwise, access must be serialised.

func New

func New(addr string) (Transport, error)

New establishes a connection to a UDP endpoint. Most implementations should defer a call to Close() immediately after the error check.

It is strongly recommended to use an IP address literal rather than hostname, as the exporter only re-connects on error, so may hold onto the original address long after DNS changes. If a hostname is passed, A records take priority over AAAA to follow the Go design decision referenced in issue #35. To force IPv6, hardcode the IP literal. We assume a BMC has a single address, so no attempt is made to try successive A records if multiple ones are returned.

Jump to

Keyboard shortcuts

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