fsio

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NopWriteCloser added in v0.0.5

func NopWriteCloser(w io.Writer) io.WriteCloser

NopWriteCloser nop closer for writer

func TryFlush

func TryFlush(w io.Writer) error

TryFlush try flush

Types

type AsyncWriter added in v0.0.5

type AsyncWriter struct {
	// Writer 实际 writer,必填
	Writer io.Writer

	// ChanSize 异步队列大小,可选
	// 默认为 1024。当值为 -1 时,chanSize=0,即变为同步
	ChanSize int

	// NeedStatus 是否需要 write 的状态
	NeedStatus bool
	// contains filtered or unexported fields
}

AsyncWriter 异步化的 writer

func (*AsyncWriter) Close added in v0.0.5

func (aw *AsyncWriter) Close() error

Close 关闭

func (*AsyncWriter) LastWriteStatus added in v0.0.5

func (aw *AsyncWriter) LastWriteStatus() WriteStatus

LastWriteStatus 返回的是异步写的最新一次的状态

func (*AsyncWriter) Write added in v0.0.5

func (aw *AsyncWriter) Write(p []byte) (n int, err error)

Write 异步写

type Flusher added in v0.0.5

type Flusher interface {
	Flush() error
}

Flusher can flush

type MutexWriter added in v0.0.5

type MutexWriter struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

func NewMutexWriter added in v0.0.6

func NewMutexWriter(w io.Writer) *MutexWriter

NewMutexWriter wrap a writer with a mutex

func (*MutexWriter) WithLock added in v0.0.6

func (w *MutexWriter) WithLock(fn func(w io.Writer))

func (*MutexWriter) WithRLock added in v0.0.6

func (w *MutexWriter) WithRLock(fn func(w io.Writer))

func (*MutexWriter) Write added in v0.0.6

func (w *MutexWriter) Write(b []byte) (int, error)

type ResetWriter

type ResetWriter interface {
	io.Writer
	Reset(w io.Writer)
}

ResetWriter writer can reset

func NewResetWriter

func NewResetWriter(w io.Writer) ResetWriter

NewResetWriter wrap writer to ResetWriter

type WriteStatus added in v0.0.5

type WriteStatus struct {
	Err   error
	Wrote int
}

WriteStatus status for Write

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL