Documentation ¶
Overview ¶
Package netw is a wrapper around network connections that stores annotations and records metrics.
Index ¶
- func Listen(network, laddr string) (net.Listener, error)
- func SetAnnotation(conn net.Conn, key string, value any)
- type Conn
- func (c *Conn) Annotation(key string, defaultValue any) any
- func (c *Conn) ByteRateReceived() float64
- func (c *Conn) ByteRateSent() float64
- func (c *Conn) BytesReceived() int64
- func (c *Conn) BytesSent() int64
- func (c *Conn) Close() error
- func (c *Conn) OnClose(f func())
- func (c *Conn) Peek(b []byte) (int, error)
- func (c *Conn) Read(b []byte) (int, error)
- func (c *Conn) SetAnnotation(key string, value any)
- func (c *Conn) SetCounters(sent, received *counter.Counter)
- func (c *Conn) SetLimiters(ingress, egress *rate.Limiter)
- func (c *Conn) StreamID() int64
- func (c *Conn) Write(b []byte) (int, error)
- type QUICConn
- func (*QUICConn) Annotation(key string, defaultValue any) any
- func (*QUICConn) ByteRateReceived() float64
- func (*QUICConn) ByteRateSent() float64
- func (*QUICConn) BytesReceived() int64
- func (*QUICConn) BytesSent() int64
- func (*QUICConn) SetAnnotation(key string, value any)
- func (*QUICConn) Streams() []*QUICStream
- type QUICStream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
Conn is a wrapper around net.Conn that stores annotations and metrics.
func NewConnForTest ¶ added in v0.4.3
func (*Conn) Annotation ¶
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
ByteRateReceived returns the rate of bytes received on this connection in the last minute.
func (*Conn) ByteRateSent ¶ added in v0.4.1
ByteRateSent returns the rate of bytes sent on this connection in the last minute.
func (*Conn) BytesReceived ¶
BytesReceived returns the number of bytes received on this connection so far.
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) SetAnnotation ¶
SetAnnotation sets an annotation. The value can be any go value.
func (*Conn) SetCounters ¶ added in v0.4.1
func (*Conn) SetLimiters ¶ added in v0.0.34
SetLimiter sets the rate limiters for this connection. It must be called before the first Read() or Write(). Peek() is OK.
type QUICConn ¶ added in v0.3.0
func (*QUICConn) Annotation ¶ added in v0.4.3
func (*QUICConn) ByteRateReceived ¶ added in v0.4.3
func (*QUICConn) ByteRateSent ¶ added in v0.4.3
func (*QUICConn) BytesReceived ¶ added in v0.4.3
func (*QUICConn) SetAnnotation ¶ added in v0.4.3
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