buffer

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 3 Imported by: 1

README

go-buffer

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFull             = errors.New("buffer is full")
	ErrOperationTimeout = errors.New("operation timed-out")
)

Functions

This section is empty.

Types

type Buffer added in v1.1.0

type Buffer struct {
	io.Closer
	// contains filtered or unexported fields
}

Buffer represents a data buffer that is asynchronously flushed, either manually or automatically.

func New added in v1.1.0

func New(size uint, flusher func([]interface{}), opts ...Option) (*Buffer, error)

New creates a new buffer instance

func (*Buffer) Close added in v1.1.0

func (buffer *Buffer) Close() error

Close flushes the buffer and prevents it from being further used.

func (*Buffer) Flush added in v1.1.0

func (buffer *Buffer) Flush() error

Flush outputs the buffer to a permanent destination. It might return an error if the buffer is already being flushed.

func (*Buffer) Push added in v1.1.0

func (buffer *Buffer) Push(item interface{}) error

Push appends an item to the end of the Buffer. It might return an error if the buffer is full.

type Option added in v1.1.0

type Option func(*Options)

func WithAutoFlush added in v1.1.0

func WithAutoFlush(interval time.Duration) Option

func WithCloseTimeout added in v1.1.0

func WithCloseTimeout(timeout time.Duration) Option

func WithFlushTimeout added in v1.1.0

func WithFlushTimeout(timeout time.Duration) Option

func WithPushTimeout added in v1.1.0

func WithPushTimeout(timeout time.Duration) Option

type Options added in v1.1.0

type Options struct {
	AutoFlush         bool
	AutoFlushInterval time.Duration
	PushTimeout       time.Duration
	FlushTimeout      time.Duration
	CloseTimeout      time.Duration
}

Jump to

Keyboard shortcuts

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