query

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2016 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessGraph

func ProcessGraph(ctx context.Context, sg, parent *SubGraph, rch chan error)

ProcessGraph processes the SubGraph instance accumulating result for the query from different instances. Note: taskQuery is nil for root node.

Types

type Codec added in v0.4.3

type Codec struct{}

Codec implements the custom codec interface.

func (*Codec) Marshal added in v0.4.3

func (c *Codec) Marshal(v interface{}) ([]byte, error)

Marshal release the graph.Node pointers after marshalling the response.

func (*Codec) String added in v0.4.3

func (c *Codec) String() string

func (*Codec) Unmarshal added in v0.4.3

func (c *Codec) Unmarshal(data []byte, v interface{}) error

Unmarshal constructs graph.Request from the byte slice.

type Latency

type Latency struct {
	Start          time.Time     `json:"-"`
	Parsing        time.Duration `json:"query_parsing"`
	Processing     time.Duration `json:"processing"`
	Json           time.Duration `json:"json_conversion"`
	ProtocolBuffer time.Duration `json:"pb_conversion"`
}

Latency is used to keep track of the latency involved in parsing and processing the query. It also contains information about the time it took to convert the result into a format(JSON/Protocol Buffer) that the client expects.

func (*Latency) ToMap

func (l *Latency) ToMap() map[string]string

ToMap converts the latency object to a map.

type SubGraph

type SubGraph struct {
	Attr   string
	Params params

	// SrcUIDs is a list of unique source UIDs. They are always copies of destUIDs
	// of parent nodes in GraphQL structure.
	SrcUIDs *task.List
	SrcFunc []string

	FilterOp string
	Filters  []*SubGraph
	Children []*SubGraph

	// destUIDs is a list of destination UIDs, after applying filters, pagination.
	DestUIDs *task.List
	// contains filtered or unexported fields
}

SubGraph is the way to represent data internally. It contains both the query and the response. Once generated, this can then be encoded to other client convenient formats, like GraphQL / JSON.

func ToSubGraph

func ToSubGraph(ctx context.Context, gq *gql.GraphQuery) (*SubGraph, error)

ToSubGraph converts the GraphQuery into the internal SubGraph instance type.

func (*SubGraph) DebugPrint added in v0.7.0

func (sg *SubGraph) DebugPrint(prefix string)

DebugPrint prints out the SubGraph tree in a nice format for debugging purposes.

func (*SubGraph) ToJSON added in v0.4.4

func (sg *SubGraph) ToJSON(l *Latency) ([]byte, error)

ToJSON converts the internal subgraph object to JSON format which is then\ sent to the HTTP client.

func (*SubGraph) ToProtocolBuffer

func (sg *SubGraph) ToProtocolBuffer(l *Latency) (*graph.Node, error)

ToProtocolBuffer does preorder traversal to build a proto buffer. We have used postorder traversal before, but preorder seems simpler and faster for most cases.

Directories

Path Synopsis
Package graph is a generated protocol buffer package.
Package graph is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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