kernel

package
v0.0.0-...-6a20a75 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TypeObjectGraph returns raw data
	TypeObjectGraph = iota
	// TypeAtomGraph returns first data
	TypeAtomGraph
)
View Source
const (
	// ErrWrongTypeCall means call method on wrong type
	ErrWrongTypeCall = "call the %s method on %s of wrong type %d"
	// ErrPushOverflow means data push overflow
	ErrPushOverflow = "graph data push overflow"
)
View Source
const (
	//TypeString describes the string type.
	TypeString = iota
	//TypeFloat64 describes the float64 type.
	TypeFloat64
	//TypeObject describes the map[string]GraphData type.
	TypeObject
	//TypeObjectArray describes the []map[string]GraphData type.
	TypeObjectArray
	//TypeArray describes the []string, []float64, [][...] type.
	TypeArray
)
View Source
const (
	// ErrWrongArgNumber means wrong number of parameters
	ErrWrongArgNumber = "method %s expects %d parameters, but %d received"
	// ErrFatalError means fatal error occurred
	ErrFatalError = "fatal error occurred while %s"
)
View Source
const (
	// TypeRootNode is the name of the virtual root node
	TypeRootNode = "__ROOT__"
)

Variables

This section is empty.

Functions

func IsVisualKey

func IsVisualKey(name string) bool

IsVisualKey determines whether a key is a virtual key based on the key name

Types

type Error

type Error struct {
	Err string `json:"error"`
}

Error represents a error's specification.

func (Error) Error

func (msg Error) Error() string

Error implements the error interface.

func (*Error) JSON

func (msg *Error) JSON() interface{}

JSON used to marshal Error to json map

func (*Error) MarshalJSON

func (msg *Error) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

type Errors

type Errors []*Error

Errors is a collection of Error

func (Errors) Errors

func (a Errors) Errors() []string

Errors returns an array will all the error messages. Example:

c.Error(errors.New("first"))
c.Error(errors.New("second"))
c.Error(errors.New("third"))
c.Errors.Errors() // == []string{"first", "second", "third"}

func (Errors) JSON

func (a Errors) JSON() interface{}

JSON used to marshal Errors to json string

func (Errors) MarshalJSON

func (a Errors) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

func (Errors) String

func (a Errors) String() string

type Graph

type Graph struct {
	// Root is the virtual root node
	Root *GraphNode
	// Nodes is the user node.
	Nodes []*GraphNode
	// GraphType identifies the output form of Graph.
	GraphType int
	// Data stores analytic data.
	Data   GraphRawData
	Errors Errors
}

Graph is a parsed Graph tree

func (*Graph) Parse

func (graph *Graph) Parse(document string) *GraphResponse

Parse builds the relationship between user nodes and ROOT nodes, parse all node data and returns.

type GraphData

type GraphData struct {
	Name  string
	Dtype int

	Dstring      string
	Dfloat64     float64
	Dobject      GraphObject
	DobjectArray []GraphObject
	Darray       []*GraphData
}

GraphData is the generic memory of Graph.

func NewGraphData

func NewGraphData(name string, dataType int) *GraphData

NewGraphData is used to initialize a GraphData.

func (*GraphData) Output

func (data *GraphData) Output() GraphRawData

Output is used to output the corresponding type of data from GraphData

func (*GraphData) Push

func (data *GraphData) Push(index int, key string, val *GraphData) (err error)

Push is used to push new value to Array or ObjectArray type GraphData.

func (*GraphData) Set

func (data *GraphData) Set(key string, val *GraphData) (err error)

Set is used to set new value to Object type GraphData.

func (*GraphData) Value

func (data *GraphData) Value(val string) (err error)

Value used to set atomized values for GraphData

type GraphNode

type GraphNode struct {
	Name       string
	Definition string
	Pipelines  pipeline.Pipelines
	Children   []*GraphNode
	NodeType   int

	Selection selector.Selection
	Parent    *GraphNode
	// contains filtered or unexported fields
}

GraphNode is the atomic node in Graph.

func (*GraphNode) Parse

func (node *GraphNode) Parse() *GraphData

Parse recursively resolves all nodes

func (*GraphNode) String

func (node *GraphNode) String() string

String method of the node returns the Text of selection.

type GraphObject

type GraphObject map[string]*GraphData

GraphObject is GraphData organized by map

type GraphRawData

type GraphRawData = interface{}

GraphRawData used to store JSON structure

func OutputObject

func OutputObject(data GraphObject, atomOnly bool) GraphRawData

OutputObject is used to traverse the data in output GraphObject if atomOnly is true, only one key will be returned

type GraphResponse

type GraphResponse struct {
	Data   GraphRawData `json:"data"`
	Errors Errors       `json:"errors"`
}

GraphResponse is the analytic result.

func (*GraphResponse) Decode

func (response *GraphResponse) Decode(obj interface{}) error

Decode is used to map Response.Data to a given struct

func (*GraphResponse) JSON

func (response *GraphResponse) JSON() (conseq string)

JSON is used to convert response to JSON string

func (*GraphResponse) MarshalData

func (response *GraphResponse) MarshalData() (string, error)

MarshalData is used to convert Response.Data to a JSON string

func (*GraphResponse) String

func (response *GraphResponse) String() (conseq string)

type H

type H map[string]interface{}

H is a shortcut for map[string]interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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