writer

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogEntry = "%s %s\n"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EntryWriter

type EntryWriter interface {
	// WriteEntry handles sending the log to the output
	// To maintain consistent log timing, Write is expected to be non-blocking
	WriteEntry(ts time.Time, entry string)
	Stop()
}

type Push

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

Push is a io.Writer, that writes given log entries by pushing directly to the given loki server URL. Each `Push` instance handles for a single tenant. No batching of log lines happens when sending to Loki.

func NewPush

func NewPush(
	lokiAddr, tenantID string,
	timeout time.Duration,
	cfg config.HTTPClientConfig,
	labelName, labelValue string,
	streamName, streamValue string,
	useTLS bool,
	tlsCfg *tls.Config,
	caFile, certFile, keyFile string,
	username, password string,
	backoffCfg *backoff.Config,
	logger log.Logger,
) (*Push, error)

NewPush creates an instance of `Push` which writes logs directly to given `lokiAddr`

func (*Push) Stop

func (p *Push) Stop()

Stop will cancel any ongoing requests and stop the goroutine listening for requests

func (*Push) WriteEntry

func (p *Push) WriteEntry(ts time.Time, e string)

WriteEntry implements EntryWriter

type StreamWriter

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

func NewStreamWriter

func NewStreamWriter(w io.Writer, logger log.Logger) *StreamWriter

func (*StreamWriter) Stop

func (s *StreamWriter) Stop()

func (*StreamWriter) WriteEntry

func (s *StreamWriter) WriteEntry(ts time.Time, entry string)

type Writer

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

func NewWriter

func NewWriter(
	writer EntryWriter,
	sentChan chan time.Time,
	entryInterval, outOfOrderMin, outOfOrderMax time.Duration,
	outOfOrderPercentage, entrySize int,
	logger log.Logger,
) *Writer

func (*Writer) Stop

func (w *Writer) Stop()

Jump to

Keyboard shortcuts

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