query

package
v0.0.0-...-8487dac Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package query parses Graphite queries into an abstract syntax tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expr

type Expr interface {
	// contains filtered or unexported methods
}

An Expr represents a graphite query subexpression.

type Func

type Func struct {
	Name string // The name of the function
	Args []Expr // zero or more arguments
}

A Func represents a function call.

func (*Func) String

func (f *Func) String() string

type Metric

type Metric string

A Metric is the name of a graphite metric, a list of words separated by dots. If a Metric contains a glob pattern, it can be expanded to multiple metrics using the Expand method.

func (Metric) Expand

func (m Metric) Expand() []Metric

If a Metric contains any brace expansions, Expand expands them and returns a slice of Metrics for each expansion. Otherwise, Expand returns a single-element slice containing the original Metric.

func (Metric) Match

func (m Metric) Match(name string) bool

Match returns true if the metric is equal to or matches name

func (Metric) Split

func (m Metric) Split() (first, rest Metric)

Split splits m immediately following the first dot

func (*Metric) String

func (m *Metric) String() string

type Query

type Query struct {
	Expr
}

A Query is a parsed graphite target query, and may consist of a single metric name (or glob), or a function call.

func Parse

func Parse(query string) (*Query, error)

Parse parses a graphite query. The various expressions in a query can be accessed and modified through the methods on the returned Query value.

func (*Query) Metrics

func (q *Query) Metrics() []*Metric

Metrics returns a slice of pointers to all metric names referenced in a query. The Metrics may be mutated through the pointer values to affect the output of the Query's String method.

func (*Query) String

func (q *Query) String() string

String produces the string representation of a (possibly modified) query. The return value is not url-encoded.

type Value

type Value string

A Value is a literal number, or a quoted string literal, which may contain arbitrary utf8-encoded characters. Numbers are represented as strings to avoid any loss in precision to repeated floating-point conversions.

func (*Value) String

func (v *Value) String() string

Jump to

Keyboard shortcuts

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