Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountReader ¶ added in v0.1.81
CountReader creates an io.Reader that counts bytes read from r, using the provided Counter.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a thread-safe utility for counting values, starting from zero.
type CounterReader ¶ added in v0.1.81
type CounterReader struct {
// contains filtered or unexported fields
}
CounterReader wraps an io.Reader to count the number of bytes read.
func NewCounterReader ¶ added in v0.1.81
func NewCounterReader(r io.Reader, c *Counter) *CounterReader
NewCounterReader creates a CounterReader that counts bytes read from r, using the provided Counter. If c is nil, a new Counter is created.
func (*CounterReader) Bytes ¶ added in v0.1.81
func (r *CounterReader) Bytes() int64
Bytes returns the total number of bytes read.
type CounterWriter ¶ added in v0.1.81
type CounterWriter struct {
// contains filtered or unexported fields
}
CounterWriter wraps an io.Writer to count the number of bytes written.
func NewCounterWriter ¶ added in v0.1.81
func NewCounterWriter(w io.Writer, c *Counter) *CounterWriter
NewCounterWriter creates a CounterWriter that counts bytes written to w, using the provided Counter. If c is nil, a new Counter is created.
func (*CounterWriter) Bytes ¶ added in v0.1.81
func (w *CounterWriter) Bytes() int64
Bytes returns the total number of bytes written.
type Listener ¶
Listener wraps a net.Listener to count bytes read and written across all connections.
func NewListener ¶
NewListener creates a Listener that counts bytes read and written across all connections.
func (*Listener) Accept ¶
Accept accepts a connection and wraps it with byte counting for reads and writes. It returns the wrapped connection or an error if the accept fails.
func (*Listener) ReadBytes ¶ added in v0.1.81
ReadBytes returns the total number of bytes read across all connections.
func (*Listener) WriteBytes ¶ added in v0.1.81
WriteBytes returns the total number of bytes written across all connections.