ast

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FuncLower = NewGroupingFunc("lower", "lowerUTF8(?)")
	FuncUpper = NewGroupingFunc("upper", "upperUTF8(?)")
)

Functions

func IsIdent

func IsIdent(s string) bool

func Parse

func Parse(s string) (any, error)

func SplitAliasName

func SplitAliasName(s string) (string, string)

func String

func String(expr Expr) string

Types

type BinaryExpr

type BinaryExpr struct {
	Op       BinaryOp
	LHS, RHS Expr
}

func (*BinaryExpr) AppendString

func (e *BinaryExpr) AppendString(b []byte) []byte

func (*BinaryExpr) AppendTemplate

func (e *BinaryExpr) AppendTemplate(b []byte) []byte

type BinaryOp

type BinaryOp string

type BoolOp

type BoolOp string
const (
	BoolAnd BoolOp = "AND"
	BoolOr  BoolOp = "OR"
)

type Expr

type Expr interface {
	AppendString(b []byte) []byte
	AppendTemplate(b []byte) []byte
}

type Filter

type Filter struct {
	BoolOp BoolOp
	LHS    string
	Op     FilterOp
	RHS    Value
}

func (*Filter) AppendString

func (f *Filter) AppendString(b []byte, spaceAround bool) []byte

type FilterOp

type FilterOp string
const (
	FilterEqual     FilterOp = "="
	FilterNotEqual  FilterOp = "!="
	FilterLT        FilterOp = "<"
	FilterLTE       FilterOp = "<="
	FilterGT        FilterOp = ">"
	FilterGTE       FilterOp = ">="
	FilterIn        FilterOp = "in"
	FilterNotIn     FilterOp = "not in"
	FilterRegexp    FilterOp = "~"
	FilterNotRegexp FilterOp = "!~"
	FilterLike      FilterOp = "like"
	FilterNotLike   FilterOp = "not like"
	FilterExists    FilterOp = "exists"
	FilterNotExists FilterOp = "not exists"
)

type Filters

type Filters []Filter

func (Filters) AppendString

func (filters Filters) AppendString(b []byte) []byte

type Func

type Func struct {
	Name string
	Expr string
}

func NewGroupingFunc

func NewGroupingFunc(name, expr string) *Func

func (*Func) AppendQuery

func (f *Func) AppendQuery(b []byte, arg ch.Safe) (_ []byte, err error)

type FuncCall

type FuncCall struct {
	Func     string
	Arg      Expr
	Grouping GroupingElems
}

func (*FuncCall) AppendString

func (fn *FuncCall) AppendString(b []byte) []byte

func (*FuncCall) AppendTemplate

func (fn *FuncCall) AppendTemplate(b []byte) []byte

type Grouping

type Grouping struct {
	Elems GroupingElems
}

func (*Grouping) String

func (g *Grouping) String() string

type GroupingElem

type GroupingElem struct {
	Func     string
	Name     string
	HasAlias bool
	Alias    string
}

func (GroupingElem) AppendString

func (g GroupingElem) AppendString(b []byte) []byte

type GroupingElems

type GroupingElems []GroupingElem

func (GroupingElems) AppendString

func (els GroupingElems) AppendString(b []byte) []byte

func (GroupingElems) Attrs

func (els GroupingElems) Attrs() []string

type MetricExpr

type MetricExpr struct {
	Name         string
	Filters      []Filter
	RollupWindow time.Duration
	Offset       time.Duration
	Grouping     GroupingElems
}

func (*MetricExpr) AppendString

func (me *MetricExpr) AppendString(b []byte) []byte

func (*MetricExpr) AppendTemplate

func (me *MetricExpr) AppendTemplate(b []byte) []byte

type NamedExpr

type NamedExpr struct {
	Expr     Expr
	HasAlias bool
	Alias    string
}

func (*NamedExpr) AppendString

func (e *NamedExpr) AppendString(b []byte) []byte

type Number

type Number struct {
	Text string
	Kind NumberKind
}

func (Number) AppendString

func (n Number) AppendString(b []byte) []byte

func (Number) AppendTemplate

func (n Number) AppendTemplate(b []byte) []byte

func (Number) ConvertValue

func (n Number) ConvertValue(unit string) (float64, error)

func (Number) Float64

func (n Number) Float64() float64

func (Number) String

func (n Number) String() string

type NumberKind

type NumberKind int
const (
	NumberUnitless NumberKind = iota
	NumberDuration
	NumberBytes
)

type ParenExpr

type ParenExpr struct {
	Expr
}

func (ParenExpr) AppendString

func (e ParenExpr) AppendString(b []byte) []byte

func (ParenExpr) AppendTemplate

func (e ParenExpr) AppendTemplate(b []byte) []byte

type QueryPart

type QueryPart interface {
	fmt.Stringer
}

type Selector

type Selector struct {
	Expr NamedExpr
}

func (*Selector) String

func (sel *Selector) String() string

type StringValue

type StringValue struct {
	Text string
}

func (StringValue) AppendString

func (v StringValue) AppendString(b []byte) []byte

type StringValues

type StringValues struct {
	Values []string
}

func (StringValues) AppendString

func (v StringValues) AppendString(b []byte) []byte

type Token

type Token struct {
	ID    TokenID
	Text  string
	Start int
}

func (*Token) String

func (t *Token) String() string

type TokenID

type TokenID int8
const (
	EOF_TOKEN TokenID = iota
	BYTE_TOKEN
	IDENT_TOKEN
	VALUE_TOKEN
	NUMBER_TOKEN
	DURATION_TOKEN
	BYTES_TOKEN
)

func (TokenID) String

func (i TokenID) String() string

type UniqExpr

type UniqExpr struct {
	Name  *MetricExpr
	Attrs []string
}

func (*UniqExpr) AppendString

func (uq *UniqExpr) AppendString(b []byte) []byte

func (*UniqExpr) AppendTemplate

func (uq *UniqExpr) AppendTemplate(b []byte) []byte

type Value

type Value interface {
	AppendString(b []byte) []byte
}

type Where

type Where struct {
	Filters Filters
}

func (*Where) String

func (w *Where) String() string

Jump to

Keyboard shortcuts

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