gordian

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShortRead = errors.New("read too short")

Functions

func Pipe

func Pipe() (*Reader, *Writer)

Pipe creates a synchronous in-memory pipe. It can be used to connect multiple passes in the Gordian program.

It relies internally on a circular buffer to pass data between the Gordian passes without copy.

It is safe to call Read and Write in parallel with each other or with Close. Parallel calls to Read and parallel calls to Write are not safe.

func ReadLine

func ReadLine(r *Reader) bool

Types

type Bzip2

type Bzip2 struct{}

func (*Bzip2) Init

func (g *Bzip2) Init(_ *regexp.Regexp)

func (*Bzip2) Pipe

func (g *Bzip2) Pipe(in io.Reader, out io.WriteCloser) error

type DragEnd added in v0.1.1

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

func (*DragEnd) Init added in v0.1.1

func (d *DragEnd) Init(re *regexp.Regexp)

func (*DragEnd) Pipe added in v0.1.1

func (d *DragEnd) Pipe(in io.Reader, out io.WriteCloser) error

type GroupML

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

GroupML re-assemble records spread over multiple lines. Given a specific pattern (regular expression), lines are grouped according to heuristic:

  1. if the current line matches the pattern, *as long as*
  2. the next line does not the pattern, *and*
  3. the next line is not an empty line

then they all belong to the same record.

func (*GroupML) Init

func (grp *GroupML) Init(re *regexp.Regexp)

func (*GroupML) Pipe

func (grp *GroupML) Pipe(in io.Reader, out io.WriteCloser) error

type Gzip

type Gzip struct{}

func (*Gzip) Init

func (g *Gzip) Init(_ *regexp.Regexp)

func (*Gzip) Pipe

func (g *Gzip) Pipe(in io.Reader, out io.WriteCloser) error

type Ignore

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

func (*Ignore) Init

func (i *Ignore) Init(re *regexp.Regexp)

func (*Ignore) Pipe

func (i *Ignore) Pipe(in io.Reader, out io.WriteCloser) error

type MaybeBzip2

type MaybeBzip2 Bzip2

func (*MaybeBzip2) Init

func (g *MaybeBzip2) Init(_ *regexp.Regexp)

func (*MaybeBzip2) Pipe

func (g *MaybeBzip2) Pipe(in io.Reader, out io.WriteCloser) error

type MaybeGzip

type MaybeGzip Gzip

func (*MaybeGzip) Init

func (g *MaybeGzip) Init(_ *regexp.Regexp)

func (*MaybeGzip) Pipe

func (g *MaybeGzip) Pipe(in io.Reader, out io.WriteCloser) error

type NoEmpty

type NoEmpty struct{}

func (*NoEmpty) Init

func (*NoEmpty) Init(_ *regexp.Regexp)

func (*NoEmpty) Pipe

func (e *NoEmpty) Pipe(in io.Reader, out io.WriteCloser) error

type Only

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

func (*Only) Init

func (o *Only) Init(re *regexp.Regexp)

func (*Only) Pipe

func (o *Only) Pipe(in io.Reader, out io.WriteCloser) error

type Pipeline

type Pipeline = []Transform

func Compile

func Compile(prg string) (Pipeline, error)

language syntax:

expr = trans { "|" trans }.
trans = name { arg } .
arg = regexp | string .
regexp = "/" validregexp "/" .
string = "\"" validgostring "\"" .

type Reader

type Reader struct {
	MaxSize int
	// contains filtered or unexported fields
}

func (*Reader) Next

func (r *Reader) Next(n int) bool

Next will try to read up to n bytes from the corresponding writer. It might read less bytes if [MaxSize] is reached. It return false if the corresponding writer is closed, and all bytes have been read.

func (*Reader) Read

func (r *Reader) Read(dt []byte) (int, error)

func (*Reader) Release

func (r *Reader) Release(n int)

Release frees up n bytes in the underlying pipe. Calling Release invalidates bytes returned by Window.

func (*Reader) Window

func (r *Reader) Window() []byte

Window returns the current window viewed by the reader Bytes returned by Window are only valid between a call to Next, and a call to Release

type Transform

type Transform interface {
	Init(*regexp.Regexp)
	Pipe(io.Reader, io.WriteCloser) error
}

type UnixYear added in v0.1.2

type UnixYear struct{}

One of the most specialized operator: if the date field look like a month, fill in the year. Year is current one, except if log month is Dec and current month is january, in case this is past year. This heuristic matches broadly what is expected looking at logs.

func (*UnixYear) Init added in v0.1.2

func (*UnixYear) Init(_ *regexp.Regexp)

func (*UnixYear) Pipe added in v0.1.2

func (e *UnixYear) Pipe(in io.Reader, out io.WriteCloser) error

type Writer

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

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Write

func (w *Writer) Write(dt []byte) (int, error)

BUG(rdo) there is a deadlock condition here: if the Write needs to go to the slow path, and wait for the Read to happen, and that there are not enough Read to release space, we can deadlock.

Notes

Bugs

  • there is a deadlock condition here: if the Write needs to go to the slow path, and wait for the Read to happen, and that there are not enough Read to release space, we can deadlock.

Directories

Path Synopsis
cmd
internal
txtar
Evolution of golang.org/x/tools/txtar, handling encoding for binary data
Evolution of golang.org/x/tools/txtar, handling encoding for binary data

Jump to

Keyboard shortcuts

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