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) 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) Write(b []byte) (int, error)
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 (*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) 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.
Click to show internal directories.
Click to hide internal directories.