asyncwriter

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package AsyncWriter implements the io.Writer which batch writes (maybe writev if it's net.Conn) to writer by channel

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAsyncWriterClosed indicates the writer was closed.
	ErrAsyncWriterClosed = errors.New("asyncwriter: writer was closed")

	// ErrAsyncWriterTooManyWrite indicates writer cannot process the write because of
	// too many write.
	ErrAsyncWriterTooManyWrite = errors.New("asyncwriter: writer wrote too fast")
)

Functions

This section is empty.

Types

type AsyncWriter

type AsyncWriter struct {
	// contains filtered or unexported fields
}

func New

func New(w io.Writer, options ...AsyncWriterOptionSetter) (*AsyncWriter, error)

func (*AsyncWriter) Close

func (bw *AsyncWriter) Close() error

func (*AsyncWriter) DoWrite

func (bw *AsyncWriter) DoWrite() error

func (*AsyncWriter) GetMetrics

func (bw *AsyncWriter) GetMetrics() *Metrics

func (*AsyncWriter) IsClosed

func (bw *AsyncWriter) IsClosed() bool

func (*AsyncWriter) Write

func (bw *AsyncWriter) Write(d []byte) (int, error)

type AsyncWriterOptionSetter

type AsyncWriterOptionSetter interface {
	// contains filtered or unexported methods
}

type AsyncWriterOptionSetterFunc

type AsyncWriterOptionSetterFunc func(*AsyncWriter)

func WithAsyncWriterMetrics

func WithAsyncWriterMetrics(m *Metrics) AsyncWriterOptionSetterFunc

func WithAsyncWriterOption

func WithAsyncWriterOption(o *Option) AsyncWriterOptionSetterFunc

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics() *Metrics

func (*Metrics) AddBytes

func (m *Metrics) AddBytes(n int64)

func (*Metrics) AddCommands

func (m *Metrics) AddCommands()

func (*Metrics) AddPendingCommands

func (m *Metrics) AddPendingCommands(n int64)

func (*Metrics) GetBytes

func (m *Metrics) GetBytes() int64

func (*Metrics) GetCommands

func (m *Metrics) GetCommands() int64

func (*Metrics) GetPendingCommands

func (m *Metrics) GetPendingCommands() int64

func (*Metrics) SetBytes

func (m *Metrics) SetBytes(i *int64)

func (*Metrics) SetCommands

func (m *Metrics) SetCommands(i *int64)

func (*Metrics) SetPendingCommands

func (m *Metrics) SetPendingCommands(i *int64)

type Option

type Option struct {
	// contains filtered or unexported fields
}

Option configruates the option of write.

func NewOption

func NewOption() *Option

NewOption returns a new Option.

func (*Option) AllowBlockForever

func (o *Option) AllowBlockForever() *Option

AllowBlockForever indicates caller can blockly write to io.Writer.

func (*Option) SetBatch

func (o *Option) SetBatch(b int) *Option

func (*Option) SetFlushInterval

func (o *Option) SetFlushInterval(d time.Duration) *Option

func (*Option) SetTimeout

func (o *Option) SetTimeout(d time.Duration) *Option

SetTimeout sets the timeout for write if it's net.Conn

type WriteMode

type WriteMode uint8

Jump to

Keyboard shortcuts

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