lhw

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: MIT Imports: 8 Imported by: 0

README

LogHoleWriter

Documentation

Index

Constants

View Source
const (
	DefaultQueueCap       = 1000
	DefaultPingInterval   = time.Second
	DefaultRequestTimeout = 2 * time.Second
)

Variables

View Source
var (
	ErrBadQueueCapacity  = errors.New("queue capacity invalid")
	ErrBadRequestTimeout = errors.New("request timeout invalid")
	ErrBadPingInterval   = errors.New("ping interval invalid")
	ErrSuccessCodes      = errors.New("success codes empty")
)
View Source
var ErrWriteFailed = errors.New("[loghole-writer] write data to queue failed")

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

type Option

type Option func(option *Options) error

func WithInsecure

func WithInsecure() Option

func WithLogger

func WithLogger(logger Logger) Option

func WithPingInterval

func WithPingInterval(interval time.Duration) Option

func WithQueueCap

func WithQueueCap(capacity int) Option

func WithRequestTimeout

func WithRequestTimeout(timeout time.Duration) Option

func WithSuccessCodes

func WithSuccessCodes(codes ...int) Option

type Options

type Options struct {
	// Writer settings
	QueueCap int
	Logger   Logger

	Servers        []string
	Insecure       bool
	RequestTimeout time.Duration
	PingInterval   time.Duration
	SuccessCodes   []int
}

func GetDefaultOptions

func GetDefaultOptions() *Options

GetDefaultOptions returns default configuration options for the client.

type Writer

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

func NewWriter

func NewWriter(url string, options ...Option) (writer *Writer, err error)

The url can contain secret token e.g. https://secret_token@localhost:50000 Comma separated arrays are also supported, e.g. urlA, urlB. Options start with the defaults but can be overridden.

func (*Writer) Close

func (w *Writer) Close() error

Close flushes any buffered log entries.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write writes the data to the queue if it is not full.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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