Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IdleReader ¶ added in v0.0.5
type IdleReader struct {
// contains filtered or unexported fields
}
IdleReader wraps an io.Reader and enforces an idle-read timeout. The internal timer is reset on every successful (n>0) Read; if the timer expires before another read completes, onIdle is invoked and subsequent Read calls return the error supplied by onIdle's caller via the wrapper's state. The zero timeout disables the timer (behaves as a plain pass-through).
func NewIdleReader ¶ added in v0.0.5
NewIdleReader constructs an IdleReader. onIdle is called once, asynchronously, from the timer goroutine when the idle window elapses — typically used to cancel a context so the underlying Read unblocks. idleErr is substituted for any error returned by the underlying reader after the timer has fired so callers can distinguish idle timeout from generic network/context errors.
func (*IdleReader) Read ¶ added in v0.0.5
func (ir *IdleReader) Read(p []byte) (int, error)
Read implements io.Reader.
func (*IdleReader) Stop ¶ added in v0.0.5
func (ir *IdleReader) Stop()
Stop halts the idle timer. Safe to call multiple times.