emitter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package emitter contains the ndt5-client emitter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

type Emitter interface {
	// OnDebug is emitted on debug messages.
	OnDebug(string) error

	// OnError is emitted on error mesages.
	OnError(string) error

	// OnWarning is emitted on warning messages.
	OnWarning(string) error

	// OnInfo is emitted on info messages.
	OnInfo(string) error

	// OnSpeed is emitted during the upload.
	OnSpeed(string, string) error

	// OnSummary is emitted after the test is over.
	OnSummary(s *Summary) error
}

Emitter is a generic emitter. When an event occurs, the corresponding method will be called. An error will generally mean that it's not possible to write the output. A common case where this happen is where the output is redirected to a file on a full hard disk.

See the documentation of the main package for more details on the sequence in which events may occur.

func NewHumanReadable

func NewHumanReadable() Emitter

NewHumanReadable returns a new human readable emitter.

func NewHumanReadableWithWriter

func NewHumanReadableWithWriter(w io.Writer) Emitter

NewHumanReadableWithWriter returns a new human readable emitter using the specified writer.

func NewJSON

func NewJSON(w io.Writer) Emitter

NewJSON creates a new JSON emitter

func NewQuiet

func NewQuiet(e Emitter) Emitter

NewQuiet returns a Summary emitter which emits messages via the passed Emitter.

type HumanReadable

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

HumanReadable is a human readable emitter. It emits the events generated by running a ndt5 test as pleasant stdout messages.

func (HumanReadable) OnDebug

func (h HumanReadable) OnDebug(m string) error

OnDebug handles debug messages.

func (HumanReadable) OnError

func (h HumanReadable) OnError(m string) error

OnError handles error messages.

func (HumanReadable) OnInfo

func (h HumanReadable) OnInfo(m string) error

OnInfo handles info messages.

func (HumanReadable) OnSpeed

func (h HumanReadable) OnSpeed(test string, speed string) error

OnSpeed handles a speed reporting event during a test.

func (HumanReadable) OnSummary

func (h HumanReadable) OnSummary(s *Summary) error

OnSummary handles the summary event.

func (HumanReadable) OnWarning

func (h HumanReadable) OnWarning(m string) error

OnWarning handles warning messages.

type Quiet

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

Quiet acts as a filter allowing summary and error messages only, and doesn't perform any formatting. The message is actually emitted by the embedded Emitter.

func (Quiet) OnDebug

func (q Quiet) OnDebug(string) error

OnDebug does not emit anything.

func (Quiet) OnError

func (q Quiet) OnError(m string) error

OnError emits the error event.

func (Quiet) OnInfo

func (q Quiet) OnInfo(string) error

OnInfo does not emit anything.

func (Quiet) OnSpeed

func (q Quiet) OnSpeed(string, string) error

OnSpeed does not emit anything.

func (Quiet) OnSummary

func (q Quiet) OnSummary(s *Summary) error

OnSummary handles the summary event, emitted after the test is over.

func (Quiet) OnWarning

func (q Quiet) OnWarning(string) error

OnWarning does not emit anything.

type Summary

type Summary struct {
	// ServerFQDN is the FQDN of the server used for this test.
	ServerFQDN string

	// ServerIP is the IP address of the server.
	ServerIP string

	// ClientIP is the IP address of the client.
	ClientIP string

	// DownloadUUID is the UUID of the download test.
	DownloadUUID string

	// Download is the download speed, in Mbit/s. This is measured at the
	// receiver.
	Download ValueUnitPair

	// Upload is the upload speed, in Mbit/s. This is measured at the sender.
	Upload ValueUnitPair

	// DownloadRetrans is the retransmission rate. This is based on the TCPInfo
	// values provided by the server during a download test.
	DownloadRetrans ValueUnitPair

	// MinRTT is the minimum round-trip time reported by the server in the
	// last Measurement of a download test, in milliseconds.
	MinRTT ValueUnitPair
}

Summary is a struct containing the values displayed to the user at the end of an ndt5 test.

func NewSummary

func NewSummary(FQDN string) *Summary

NewSummary returns a new Summary struct for a given FQDN.

type ValueUnitPair

type ValueUnitPair struct {
	Value float64
	Unit  string
}

ValueUnitPair represents a {"Value": ..., "Unit": ...} pair.

Jump to

Keyboard shortcuts

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