query

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package query defines the graph session interface general to all query languages.

Index

Constants

This section is empty.

Variables

View Source
var ErrParseMore = errors.New("query: more input required")

Functions

func Languages added in v0.6.0

func Languages() []string

Languages returns names of registered query languages.

func RegisterLanguage added in v0.6.0

func RegisterLanguage(lang Language)

RegisterLanguage register a new query language.

Types

type HTTP added in v0.4.1

type HTTP interface {
	Session
	ShapeOf(string) (interface{}, error)
	Collate(Result)
	Results() (interface{}, error)
}

type Language added in v0.6.0

type Language struct {
	Name    string
	Session func(graph.QuadStore) Session
	REPL    func(graph.QuadStore) REPLSession
	HTTP    func(graph.QuadStore) HTTP

	HTTPQuery func(ctx context.Context, qs graph.QuadStore, w ResponseWriter, r io.Reader)
	HTTPError func(w ResponseWriter, err error)
}

Language is a description of query language.

func GetLanguage added in v0.6.0

func GetLanguage(lang string) *Language

GetLanguage returns a query language description. It returns nil if language was not registered.

type REPLSession added in v0.6.0

type REPLSession interface {
	Session
	FormatREPL(Result) string
}

type ResponseWriter added in v0.6.0

type ResponseWriter interface {
	Write([]byte) (int, error)
	WriteHeader(int)
}

ResponseWriter is a subset of http.ResponseWriter

type Result added in v0.6.0

type Result interface {
	Result() interface{}
	Err() error
}

func ErrorResult added in v0.6.0

func ErrorResult(err error) Result

func TagMapResult added in v0.6.0

func TagMapResult(m map[string]graph.Value) Result

type Session

type Session interface {
	// Runs the query and returns individual results on the channel.
	//
	// Channel will be closed when function returns.
	Execute(ctx context.Context, query string, out chan Result, limit int)
}

func NewSession added in v0.6.0

func NewSession(qs graph.QuadStore, lang string) Session

NewSession creates a new session for specified query language. It returns nil if language was not registered.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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