Git Product home page Git Product logo

grange's Introduction

Grange

Grange implements a modern subset of the range query language. It is an expressive grammar for selecting information out of arbitrary, self-referential metadata. It was developed for querying information about hosts across datacenters.

%{has(DC;east) & has(TYPE;redis)}:DOWN

See godocs for usage and syntax.

Goals

  • Easily run cross-platform.
  • Error messages when things go wrong.
  • Fast. (Looking at you, clusters.)

Development

This is library, so does not export a main function. Run it via tests.

export RANGE_SPEC_PATH=/tmp/range-spec
git clone https://github.com/square/range-spec.git $RANGE_SPEC_PATH

go get github.com/pointlander/peg

$GOPATH/bin/peg range.peg && go test

grange's People

Contributors

achow avatar arepraneeth avatar bwester avatar drcapulet avatar fvbommel avatar jsoref avatar mbyczkowski avatar mcpherrinm avatar nwatson avatar praneeth-sq avatar xaviershay avatar xunil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grange's Issues

Allow brackets inside cluster names et. al

There are a number of range specs that have some variation of the form %a{b}c that don't currently work.

See the pending list inside expand_test.go for more examples.

Allow regex to be used on LHS of expression

(bad,mad,good) & /ad/ and /ad/ & (bad,mad,good) should be equivalent, but the latter doesn't work as expected, because first the LHS expands to nothing before the intersection applies.

The relevant range spec is marked as pending in expand_test.go

More robust numeric expansion

The current implementation of numeric expansion (see numericRangeRegex and associated code) doesn't handle some newer additions to range spec such as a1a1..a1a3 and a2a2a1..a2a2. It may be possible to patch up the regex to work, but I suspect we may need to rewrite it with less regex.

In case it's helpful, see https://github.com/xaviershay/hrange/blob/8ef7ed289ac503b6745c324090f09cea1c7cae62/src/Hrange/Parser.hs#L168

These specs are currently marked as pending in expand_test.go.

Tests fail on new range-spec test cases (after 2016)

The test cases fail with range-spec queries updated after February 2016.

a - {}
a

a, {}
a

a - ()
a

a, ()
a

%()

%{}

mem(GRO{UPS};host2)
dc1

Also, from the tests I got this bug report:

got: Set{bc}
want: Set{two, both, one}

got: Set{c}
want: Set{one, two, both}

Could not parse query: %de{f}:KEYS

expand_test.go:86: FAILED /range-spec/spec/expand/numeric_expansion.spec:31
got: Set{an1, an2, an3, an1..n03}
want: Set{an1, an2, an3}

expand_test.go:86: FAILED /range-spec/spec/expand/numeric_expansion.spec:55
got: Set{a1a1..a1a3, a1a1a3}
want: Set{a1a1, a1a2, a1a3}

expand_test.go:86: FAILED /range-spec/spec/expand/numeric_expansion.spec:61
got: Set{a2a2a1..a2a2, a2a2a1a2, a2a2a2a2}
want: Set{a2a2a1, a2a2a2}

expand_test.go:78: FAILED /range-spec/spec/expand/parsing.spec:8
Could not parse query: %a.b

expand_test.go:86: FAILED /range-spec/spec/expand/regex.spec:10
got: Set{}
want: Set{bad, mad}

expand_test.go:78: FAILED /range-spec/spec/expand/clusters/cluster_dots.spec:1
Could not parse query: %a.b.c

expand_test.go:78: FAILED /range-spec/spec/expand/clusters/cluster_dots.spec:16
Could not parse query: %a.b-c.d

expand_test.go:78: FAILED /range-spec/spec/expand/clusters/cluster_func.spec:1
Could not parse query: %allclusters()

expand_test.go:86: FAILED /range-spec/spec/expand/default_cluster/at_operator.spec:8
got: Set{cure}
want: Set{host1}

expand_test.go:78: FAILED /range-spec/spec/expand/default_cluster/mem_function.spec:1
Unknown function: mem

expand_test.go:78: FAILED /range-spec/spec/expand/default_cluster/mem_function.spec:5
Unknown function: mem

expand_test.go:86: FAILED /range-spec/spec/expand/dollar_sign/dollar_operator.spec:2
got: Set{bar2, bar1}
want: Set{$foo}

Incompatible with Go 1.11

When I was trying to run go test, I got an error:

./expand_test.go:136: Sprintf format %s has arg value.(bool) of wrong type bool

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.