Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTimeout = errors.New("Timeout")
var (
ErrTooLarge = errors.New("reader: too large only 8MB allowed as per MaxReadSize")
)
var (
// although this is more than enough for most cases
MaxReadSize, _ = units.FromHumanSize("8mb")
)
Functions ¶
func ConnReadN ¶ added in v0.0.62
ConnReadN reads at most N bytes from reader and it optimized for connection based readers like net.Conn it should not be used for file/buffer based reading, ConnReadN should be preferred instead of 'conn.Read() without loop' . It ignores EOF, UnexpectedEOF and timeout errors Note: you are responsible for adding a timeout to context
func ConnReadNWithTimeout ¶ added in v0.0.62
ConnReadNWithTimeout is same as ConnReadN but it takes timeout instead of context and it returns error if read does not finish in given time
func IsAcceptedError ¶ added in v0.0.62
IsAcceptedError checks if the error is accepted error for example: connection refused, io.EOF, io.ErrUnexpectedEOF while reading from connection
Types ¶
type KeyPressReader ¶ added in v0.0.17
type KeyPressReader struct { Timeout time.Duration Once *sync.Once Raw bool BufferSize int // contains filtered or unexported fields }
func (KeyPressReader) Read ¶ added in v0.0.17
func (reader KeyPressReader) Read(p []byte) (n int, err error)
Read into the buffer
func (*KeyPressReader) Start ¶ added in v0.0.17
func (reader *KeyPressReader) Start() error
func (*KeyPressReader) Stop ¶ added in v0.0.17
func (reader *KeyPressReader) Stop() error
type ReusableReadCloser ¶
type ReusableReadCloser struct { *sync.RWMutex io.Reader // contains filtered or unexported fields }
ReusableReadCloser is a reusable reader with no-op close
func NewReusableReadCloser ¶
func NewReusableReadCloser(raw interface{}) (*ReusableReadCloser, error)
NewReusableReadCloser is returned for any type of input
func (ReusableReadCloser) Close ¶
func (r ReusableReadCloser) Close() error
Close is a no-op close of ReusableReadCloser