Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyClosed = errors.New("writer already closed")
var ErrAttemptToWriteOnClosedFile = errors.New("cannot write to a closed or unopened file")
Functions ¶
This section is empty.
Types ¶
type Append ¶
type Append struct {
// contains filtered or unexported fields
}
type Async ¶
type Async struct {
// contains filtered or unexported fields
}
func NewAsync ¶
func NewAsync(handler io.Writer, options ...AsyncOption) *Async
NewAsync creates a writer that accumulates Write requests and writes them at a fixed rate (every 250 ms by default)
type AsyncOption ¶
type AsyncOption func(writer *Async)
func WithWriteInterval ¶
func WithWriteInterval(duration time.Duration) AsyncOption
WithWriteInterval sets the interval at which writes happen at least when data is pending
type FileOption ¶
type FileOption func(f *File)
func WithFileKeepOpen ¶
func WithFileKeepOpen(keepOpen bool) FileOption
WithFileKeepOpen toggles whether the file is kept open between writes. Defaults to true for all OS except Windows.
func WithFileKeepOpenTimeout ¶
func WithFileKeepOpenTimeout(timeout time.Duration) FileOption
WithFileKeepOpenTimeout will automatically close the file after there was no more write during `timeout`. It defaults to 10ms.
func WithFilePerm ¶
func WithFilePerm(perm os.FileMode) FileOption
WithFilePerm sets file perms to apply when creating the file
func WithFileTruncate ¶
func WithFileTruncate() FileOption
WithFileTruncate enables that existing files are truncated
type WriterAppendFunc ¶
WriterAppendFunc is called for every input byte when appending it to the output buffer (is similar to buf = append(buf, byte))