bulk

package
v7.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoErrorHandler = func(data []byte, err error) {}

NoErrorHandler is an empty function that is used when no ErrorHandler is required One may always process all their errors directly in the FlushFunc.

Functions

This section is empty.

Types

type ErrorHandlerFunc

type ErrorHandlerFunc func(data []byte, err error)

ErrorHandlerFunc is a function that gets errors occured in FlushFunc It will also get a buffer copy so that you could somehow analyze it. After this function is called, the buffer is destroyed automatically by the calling code (i.e. you do not need to clean it up yourself).

type FlushFunc

type FlushFunc func(data []byte) error

A function of a FlushFunc type once called will receive a buffer containing all the data from writes made after the previous FlushFunc call. The data buffer will be cleaned up automatically after this function is executed (i.e. you do not need to clean it up yourself). Any error returned from this function will be passed to a ErrorHandlerFunc function

type Writer

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

Writer is an implenetation of an io.WriteCloser interface. It lets creating a buffered writer that can flush (and thus physically write) the buffer by a time ticker or by manual calls of Writer.Flush().

func NewBulkWriter

func NewBulkWriter(flushInterval time.Duration, flushFunc FlushFunc) *Writer

NewBulkWriter creates a new bulk.Writer instance flushInterval - how often to call the flushFunc, if set to a nonpositive value will effectively turn

off automatic flushing

flushFunc - defines what to do on flush

func NewBulkWriterWithErrorHandler

func NewBulkWriterWithErrorHandler(flushInterval time.Duration, flushFunc FlushFunc, errorHandler ErrorHandlerFunc) *Writer

NewBulkWriterWithErrorHandler creates a new bulk.Writer instance flushInterval - how often to call the flushFunc, if set to a nonpositive value will effectively turn

off automatic flushing

flushFunc - defines what to do on flush errorHandler - whenever your flushFunc returns an error, it can be processed in this function

func (*Writer) Close

func (b *Writer) Close() error

Close is an implementation of an io.Closer interface. It closes the writer, stops any activity and any subsiquent operations will result in a error. It will return an error if called after Close() was called.

func (*Writer) Flush

func (b *Writer) Flush() error

Flush forces buffer flush. It is mainly suited for buffer flushing when automatic flushing is turned off, but you may call it even if automatic flushing is turned on. It will return an error if called after Close() was called.

func (*Writer) Write

func (b *Writer) Write(data []byte) (n int, err error)

Write is an implementation of an io.Writer interface. The data are appended to a temporary buffer that will be cleaned up on flush. It will return an error if called after Close() was called.

Jump to

Keyboard shortcuts

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