transport

package
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedTransport       = errors.New("unsupported transport")
	ErrUnsupportedPacketTransport = errors.New("unsupported Packet transport")
	ErrUnsupportedStreamTransport = errors.New("unsupported Stream transport")
)

Functions

This section is empty.

Types

type Metric

type Metric struct {
	Raw  string
	Addr net.Addr
}

type MockReporter

type MockReporter struct {
	// contains filtered or unexported fields
}

MockReporter provides a Reporter that provides some useful functionalities for tests (eg.: wait for certain number of messages).

func NewMockReporter

func NewMockReporter(expectedOnMetricsProcessedCalls int) *MockReporter

NewMockReporter returns a new instance of a MockReporter.

func (*MockReporter) OnDebugf

func (m *MockReporter) OnDebugf(_ string, _ ...any)

func (*MockReporter) WaitAllOnMetricsProcessedCalls

func (m *MockReporter) WaitAllOnMetricsProcessedCalls()

WaitAllOnMetricsProcessedCalls blocks until the number of expected calls specified at creation of the reporter is completed.

type Reporter

type Reporter interface {
	// OnDebugf allows less structured reporting for debugging scenarios.
	OnDebugf(
		template string,
		args ...any)
}

Reporter is used to report (via zPages, logs, metrics, etc) the events happening when the Server is receiving and processing data.

type Server

type Server interface {
	// ListenAndServe is a blocking call that starts to listen for client messages
	// on the specific transport, and prepares the message to be processed by
	// the Parser and passed to the next consumer.
	ListenAndServe(
		mc consumer.Metrics,
		r Reporter,
		transferChan chan<- Metric,
	) error

	// Close stops any running ListenAndServe, however, it waits for any
	// data already received to be parsed and sent to the next consumer.
	Close() error
}

Server abstracts the type of transport being used and offer an interface to handle serving clients over that transport.

func NewTCPServer added in v0.86.0

func NewTCPServer(transport Transport, address string) (Server, error)

NewTCPServer creates a transport.Server using TCP as its transport.

func NewUDPServer

func NewUDPServer(transport Transport, address string) (Server, error)

NewUDPServer creates a transport.Server using UDP as its transport.

type Transport added in v0.92.0

type Transport string

Transport is a set of constants of the transport supported by this receiver.

const (
	UDP  Transport = "udp"
	UDP4 Transport = "udp4"
	UDP6 Transport = "udp6"
	TCP  Transport = "tcp"
	TCP4 Transport = "tcp4"
	TCP6 Transport = "tcp6"
)

func NewTransport added in v0.92.0

func NewTransport(ts string) Transport

NewTransport creates a Transport based on the transport string or returns an empty Transport.

func (Transport) IsPacketTransport added in v0.92.0

func (trans Transport) IsPacketTransport() bool

IsPacketTransport returns true if the transport is packet based.

func (Transport) IsStreamTransport added in v0.92.0

func (trans Transport) IsStreamTransport() bool

IsStreamTransport returns true if the transport is stream based.

func (Transport) String added in v0.92.0

func (trans Transport) String() string

String casts the transport to a String if the Transport is supported. Return an empty Transport overwise.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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