Documentation ¶
Overview ¶
Package emitter contains the ndt7-client emitter.
Index ¶
- type Emitter
- type HumanReadable
- func (h HumanReadable) OnComplete(test spec.TestKind) error
- func (h HumanReadable) OnConnected(test spec.TestKind, fqdn string) error
- func (h HumanReadable) OnDownloadEvent(m *spec.Measurement) error
- func (h HumanReadable) OnError(test spec.TestKind, err error) error
- func (h HumanReadable) OnStarting(test spec.TestKind) error
- func (h HumanReadable) OnSummary(s *Summary) error
- func (h HumanReadable) OnUploadEvent(m *spec.Measurement) error
- type Prometheus
- func (p Prometheus) OnComplete(test spec.TestKind) error
- func (p Prometheus) OnConnected(test spec.TestKind, fqdn string) error
- func (p Prometheus) OnDownloadEvent(m *spec.Measurement) error
- func (p Prometheus) OnError(test spec.TestKind, err error) error
- func (p Prometheus) OnStarting(test spec.TestKind) error
- func (p *Prometheus) OnSummary(s *Summary) error
- func (p Prometheus) OnUploadEvent(m *spec.Measurement) error
- type Quiet
- func (q Quiet) OnComplete(test spec.TestKind) error
- func (q Quiet) OnConnected(test spec.TestKind, fqdn string) error
- func (q Quiet) OnDownloadEvent(m *spec.Measurement) error
- func (q Quiet) OnError(test spec.TestKind, err error) error
- func (q Quiet) OnStarting(test spec.TestKind) error
- func (q Quiet) OnSummary(s *Summary) error
- func (q Quiet) OnUploadEvent(m *spec.Measurement) error
- type SubtestSummary
- type Summary
- type ValueUnitPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Emitter ¶
type Emitter interface { // OnStarting is emitted before attempting to start a test. OnStarting(test spec.TestKind) error // OnError is emitted if a test cannot start. OnError(test spec.TestKind, err error) error // OnConnected is emitted when we connected to the ndt7 server. OnConnected(test spec.TestKind, fqdn string) error // OnDownloadEvent is emitted during the download. OnDownloadEvent(m *spec.Measurement) error // OnUploadEvent is emitted during the upload. OnUploadEvent(m *spec.Measurement) error // OnComplete is always emitted when the test is over. OnComplete(test spec.TestKind) 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 ¶
NewHumanReadableWithWriter returns a new human readable emitter using the specified writer.
func NewPrometheus ¶
func NewPrometheus(e Emitter, dlThroughput, dlLatency, ulThroughput, ulLatency, lastResult *prometheus.GaugeVec) Emitter
NewPrometheus 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 ndt7 test as pleasant stdout messages.
func (HumanReadable) OnComplete ¶
func (h HumanReadable) OnComplete(test spec.TestKind) error
OnComplete handles the complete event
func (HumanReadable) OnConnected ¶
func (h HumanReadable) OnConnected(test spec.TestKind, fqdn string) error
OnConnected handles the connected event
func (HumanReadable) OnDownloadEvent ¶
func (h HumanReadable) OnDownloadEvent(m *spec.Measurement) error
OnDownloadEvent handles an event emitted by the download test
func (HumanReadable) OnError ¶
func (h HumanReadable) OnError(test spec.TestKind, err error) error
OnError handles the error event
func (HumanReadable) OnStarting ¶
func (h HumanReadable) OnStarting(test spec.TestKind) error
OnStarting handles the start event
func (HumanReadable) OnSummary ¶
func (h HumanReadable) OnSummary(s *Summary) error
OnSummary handles the summary event.
func (HumanReadable) OnUploadEvent ¶
func (h HumanReadable) OnUploadEvent(m *spec.Measurement) error
OnUploadEvent handles an event emitted during the upload test
type Prometheus ¶
type Prometheus struct {
// contains filtered or unexported fields
}
Prometheus tees summary metrics as prometheus metrics. The message is actually emitted by the embedded Emitter.
func (Prometheus) OnComplete ¶
func (p Prometheus) OnComplete(test spec.TestKind) error
OnComplete is the event signalling the end of the test
func (Prometheus) OnConnected ¶
func (p Prometheus) OnConnected(test spec.TestKind, fqdn string) error
OnConnected emits the connected event
func (Prometheus) OnDownloadEvent ¶
func (p Prometheus) OnDownloadEvent(m *spec.Measurement) error
OnDownloadEvent handles an event emitted during the download
func (Prometheus) OnError ¶
func (p Prometheus) OnError(test spec.TestKind, err error) error
OnError emits the error event
func (Prometheus) OnStarting ¶
func (p Prometheus) OnStarting(test spec.TestKind) error
OnStarting emits the starting event
func (*Prometheus) OnSummary ¶
func (p *Prometheus) OnSummary(s *Summary) error
OnSummary handles the summary event, emitted after the test is over.
func (Prometheus) OnUploadEvent ¶
func (p Prometheus) OnUploadEvent(m *spec.Measurement) error
OnUploadEvent handles an event emitted during the upload
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) OnComplete ¶
OnComplete is the event signalling the end of the test
func (Quiet) OnConnected ¶
OnConnected emits the connected event
func (Quiet) OnDownloadEvent ¶
func (q Quiet) OnDownloadEvent(m *spec.Measurement) error
OnDownloadEvent handles an event emitted during the download
func (Quiet) OnStarting ¶
OnStarting emits the starting event
func (Quiet) OnUploadEvent ¶
func (q Quiet) OnUploadEvent(m *spec.Measurement) error
OnUploadEvent handles an event emitted during the upload
type SubtestSummary ¶
type SubtestSummary struct { // UUID is the unique identified of this subtest. UUID string // Throughput is the measured throughput during this subtest. Throughput ValueUnitPair // Latency is the MinRTT value of the latest measurement, in milliseconds. Latency ValueUnitPair // Retransmission is BytesRetrans / BytesSent from TCPInfo Retransmission ValueUnitPair }
SubtestSummary contains all the results of a single subtest (download or upload). All the values are from the server's perspective, except for the download throughput.
type Summary ¶
type Summary struct { // ServerFQDN is the FQDN of the server used for this test. ServerFQDN string // ServerIP is the (v4 or v6) IP address of the server. ServerIP string // ClientIP is the (v4 or v6) IP address of the client. ClientIP string // Download is a summary of the download subtest. Download *SubtestSummary // Upload is a summary of the upload subtest. Upload *SubtestSummary }
Summary is a struct containing the values displayed to the user at the end of an ndt7 test.
func NewSummary ¶
NewSummary returns a new Summary struct for a given FQDN.
type ValueUnitPair ¶
ValueUnitPair represents a {"Value": ..., "Unit": ...} pair.