netw

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package netw is a wrapper around network connections that stores annotations and records metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(network, laddr string) (net.Listener, error)

Listen creates a net listener that is instrumented to store per connection annotations and metrics.

func SetAnnotation

func SetAnnotation(conn net.Conn, key string, value any)

SetAnnotation sets an annotation on a connection. The value can be any go value.

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn is a wrapper around net.Conn that stores annotations and metrics.

func NewConn added in v0.5.2

func NewConn(c net.Conn) *Conn

func NewConnForTest added in v0.4.3

func NewConnForTest(c net.Conn) *Conn

func (*Conn) Annotation

func (c *Conn) Annotation(key string, defaultValue any) any

Annotation retrieves an annotation that was previously set on the connection. The defaultValue is returned if the annotation was never set.

func (*Conn) ByteRateReceived added in v0.4.1

func (c *Conn) ByteRateReceived() float64

ByteRateReceived returns the rate of bytes received on this connection in the last minute.

func (*Conn) ByteRateSent added in v0.4.1

func (c *Conn) ByteRateSent() float64

ByteRateSent returns the rate of bytes sent on this connection in the last minute.

func (*Conn) BytesReceived

func (c *Conn) BytesReceived() int64

BytesReceived returns the number of bytes received on this connection so far.

func (*Conn) BytesSent

func (c *Conn) BytesSent() int64

BytesSent returns the number of bytes sent on this connection so far.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) OnClose

func (c *Conn) OnClose(f func())

OnClose sets a callback function that will be called when the connection is closed.

func (*Conn) Peek

func (c *Conn) Peek(b []byte) (int, error)

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) SetAnnotation

func (c *Conn) SetAnnotation(key string, value any)

SetAnnotation sets an annotation. The value can be any go value.

func (*Conn) SetCounters added in v0.4.1

func (c *Conn) SetCounters(sent, received *counter.Counter)

func (*Conn) SetLimiters added in v0.0.34

func (c *Conn) SetLimiters(ingress, egress *rate.Limiter)

SetLimiter sets the rate limiters for this connection. It must be called before the first Read() or Write(). Peek() is OK.

func (*Conn) StreamID added in v0.3.0

func (c *Conn) StreamID() int64

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

type QUICConn added in v0.3.0

type QUICConn struct {
	net.Conn
}

func (*QUICConn) Annotation added in v0.4.3

func (*QUICConn) Annotation(key string, defaultValue any) any

func (*QUICConn) ByteRateReceived added in v0.4.3

func (*QUICConn) ByteRateReceived() float64

func (*QUICConn) ByteRateSent added in v0.4.3

func (*QUICConn) ByteRateSent() float64

func (*QUICConn) BytesReceived added in v0.4.3

func (*QUICConn) BytesReceived() int64

func (*QUICConn) BytesSent added in v0.4.3

func (*QUICConn) BytesSent() int64

func (*QUICConn) SetAnnotation added in v0.4.3

func (*QUICConn) SetAnnotation(key string, value any)

func (*QUICConn) Streams added in v0.3.0

func (*QUICConn) Streams() []*QUICStream

type QUICStream added in v0.3.0

type QUICStream struct {
	Conn
}

func (*QUICStream) BridgeAddr added in v0.3.0

func (*QUICStream) BridgeAddr() string

func (*QUICStream) Dir added in v0.3.0

func (*QUICStream) Dir() string

Jump to

Keyboard shortcuts

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