parser

package
v2.15.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package parser implements a MySQL slow log parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContinuousFileReader

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

ContinuousFileReader reads lines from the single file across renames, truncations and symlink changes.

func NewContinuousFileReader

func NewContinuousFileReader(filename string, l Logger) (*ContinuousFileReader, error)

NewContinuousFileReader creates new ContinuousFileReader.

func (*ContinuousFileReader) Close

func (r *ContinuousFileReader) Close() error

Close implements Reader interface.

func (*ContinuousFileReader) Metrics

func (r *ContinuousFileReader) Metrics() *ReaderMetrics

Metrics implements Reader interface.

func (*ContinuousFileReader) NextLine

func (r *ContinuousFileReader) NextLine() (string, error)

NextLine implements Reader interface.

type Logger

type Logger interface {
	Warnf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Debugf(format string, v ...interface{})
	Tracef(format string, v ...interface{})
}

type Reader

type Reader interface {
	// NextLine reads full lines from the underlying source and returns them (including the last '\n').
	// If the full line can't be read because of EOF, reader implementation may decide to return it,
	// or block and wait for new data to arrive. Other errors should be returned without blocking.
	// NextLine also should not block when the source is closed, but it may return buffered data while it has it.
	NextLine() (string, error)

	// Close closes the underlying source. A caller should continue to call NextLine until error is returned.
	Close() error

	// Metrics returns current metrics.
	Metrics() *ReaderMetrics
}

A Reader reads lines from the underlying source.

Implementation should allow concurrent calls to different methods.

type ReaderMetrics

type ReaderMetrics struct {
	InputSize int64
	InputPos  int64
}

ReaderMetrics contains Reader metrics.

type SimpleFileReader

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

SimpleFileReader reads lines from the single file from the start until EOF.

func NewSimpleFileReader

func NewSimpleFileReader(filename string) (*SimpleFileReader, error)

NewSimpleFileReader creates new SimpleFileReader.

func (*SimpleFileReader) Close

func (r *SimpleFileReader) Close() error

Close implements Reader interface.

func (*SimpleFileReader) Metrics

func (r *SimpleFileReader) Metrics() *ReaderMetrics

Metrics implements Reader interface.

func (*SimpleFileReader) NextLine

func (r *SimpleFileReader) NextLine() (string, error)

NextLine implements Reader interface.

type SlowLogParser

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

A SlowLogParser parses a MySQL slow log.

func NewSlowLogParser

func NewSlowLogParser(r Reader, opts log.Options) *SlowLogParser

NewSlowLogParser returns a new SlowLogParser that reads from the given reader.

func (*SlowLogParser) Err

func (p *SlowLogParser) Err() error

Err returns a reason why parsing stop. It must be called only after Parse() returned nil.

func (*SlowLogParser) Parse

func (p *SlowLogParser) Parse() *log.Event

Parse returns next parsed event, or nil, when parsing is done.

func (*SlowLogParser) Run

func (p *SlowLogParser) Run()

Run parses events until reader's NextLine() method returns error. Caller should call Parse() until nil is returned, then inspect Err().

Jump to

Keyboard shortcuts

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