measured

package module
v0.0.0-...-3d9e377 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 6 Imported by: 9 modules, 20 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

measured

Wraps a dialer to measure the total bytes sent/received as well as rates thereof.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapListener

func WrapListener(l net.Listener, rateInterval time.Duration, onFinish func(Conn)) net.Listener

WrapListener wraps an existing listener with one that will measure accepted connections.

Types

type Conn

type Conn interface {
	net.Conn

	// Stats gets the stats over the lifetime of the connection
	Stats() *Stats

	// FirstError gets the the first unexpected error encountered during network
	// processing. If this is not nil, something went wrong.
	FirstError() error

	// Wrapped() exposes the wrapped net.Conn
	Wrapped() net.Conn
}

Conn is a wrapped net.Conn that exposes statistics about transfer data and the first error encountered during processing.

func Wrap

func Wrap(wrapped net.Conn, rateInterval time.Duration, onFinish func(Conn)) Conn

Wrap wraps a connection into a measured Conn that recalculates rates at the given interval.

type Stats

type Stats struct {
	SentTotal int
	SentMin   float64
	SentMax   float64
	SentAvg   float64
	RecvTotal int
	RecvMin   float64
	RecvMax   float64
	RecvAvg   float64
	// Duration indicates how long it has been since the connection was opened
	// (more precisely, how long it's been since it was wrapped by measured).
	Duration time.Duration
}

Stats provides statistics about total transfer and rates, all in bytes.

Jump to

Keyboard shortcuts

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