flameql

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReservedTagKeyName = "__name__"
)

Variables

View Source
var (
	ErrInvalidQuerySyntax    = errors.New("invalid query syntax")
	ErrInvalidAppName        = errors.New("invalid application name")
	ErrInvalidMatchersSyntax = errors.New("invalid tag matchers syntax")
	ErrInvalidTagKey         = errors.New("invalid tag key")
	ErrInvalidTagValueSyntax = errors.New("invalid tag value syntax")

	ErrAppNameIsRequired = errors.New("application name is required")
	ErrTagKeyIsRequired  = errors.New("tag key is required")
	ErrTagKeyReserved    = errors.New("tag key is reserved")

	ErrMatchOperatorIsRequired = errors.New("match operator is required")
	ErrUnknownOp               = errors.New("unknown tag match operator")
)

Functions

func FromTreeToDictKey

func FromTreeToDictKey(k string) string

FromTreeToDictKey returns app name from tree key k: given tree key "foo{}:0:1234567890", the call returns "foo".

Before tags support, segment key form (i.e. app name + tags: foo{key=value}) has been used to reference a dictionary (trie).

func IsAppNameRuneAllowed

func IsAppNameRuneAllowed(r rune) bool

func IsTagKeyReserved

func IsTagKeyReserved(k string) bool

func IsTagKeyRuneAllowed

func IsTagKeyRuneAllowed(r rune) bool

func ParseTreeKey

func ParseTreeKey(k string) (time.Time, int, error)

ParseTreeKey retrieves tree time and depth level from the given key.

func TreeKey

func TreeKey(k string, depth int, unixTime int64) string

func ValidateAppName

func ValidateAppName(n string) error

ValidateAppName report an error if the given app name n violates constraints.

func ValidateTagKey

func ValidateTagKey(k string) error

ValidateTagKey report an error if the given key k violates constraints.

The function should be used to validate user input. The function returns ErrTagKeyReserved if the key is valid but reserved for internal use.

Types

type ByPriority

type ByPriority []*TagMatcher

ByPriority is a supplemental type for sorting tag matchers.

func (ByPriority) Len

func (p ByPriority) Len() int

func (ByPriority) Less

func (p ByPriority) Less(i, j int) bool

func (ByPriority) Swap

func (p ByPriority) Swap(i, j int)

type Error

type Error struct {
	Inner error
	Expr  string
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Key

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

func NewKey

func NewKey(labels map[string]string) *Key

func ParseKey

func ParseKey(name string) (*Key, error)

func (*Key) Add

func (k *Key) Add(key, value string)

func (*Key) AppName

func (k *Key) AppName() string

func (*Key) Clone

func (k *Key) Clone() *Key

Match reports whether the key matches the query.

func (*Key) DictKey

func (k *Key) DictKey() string

func (*Key) Labels

func (k *Key) Labels() map[string]string

func (*Key) Match

func (k *Key) Match(q *Query) bool

func (*Key) Normalized

func (k *Key) Normalized() string

func (*Key) SegmentKey

func (k *Key) SegmentKey() string

func (*Key) TreeKey

func (k *Key) TreeKey(depth int, t time.Time) string

type Op

type Op int
const (
	OpNotEqual      Op // !=
	OpNotEqualRegex    // !~
	OpEqual            // =
	OpEqualRegex       // =~
)

func (Op) IsNegation

func (o Op) IsNegation() bool

IsNegation reports whether the operator assumes negation.

type ParserState

type ParserState int

type Query

type Query struct {
	AppName  string
	Matchers []*TagMatcher
	// contains filtered or unexported fields
}

func ParseQuery

func ParseQuery(s string) (*Query, error)

ParseQuery parses a string of $app_name<{<$tag_matchers>}> form.

func (*Query) String

func (q *Query) String() string

type TagMatcher

type TagMatcher struct {
	Key   string
	Value string
	Op

	R *regexp.Regexp
}

func ParseMatcher

func ParseMatcher(s string) (*TagMatcher, error)

ParseMatcher parses a string of $tag_key$op"$tag_value" form, where $op is one of the supported match operators.

func ParseMatchers

func ParseMatchers(s string) ([]*TagMatcher, error)

ParseMatchers parses a string of $tag_matcher<,$tag_matchers> form.

func (*TagMatcher) Match

func (m *TagMatcher) Match(v string) bool

Jump to

Keyboard shortcuts

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