Documentation ¶
Index ¶
Constants ¶
const ( // TypeObjectGraph returns raw data TypeObjectGraph = iota // TypeAtomGraph returns first data TypeAtomGraph )
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" )
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 )
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" )
const (
// TypeRootNode is the name of the virtual root node
TypeRootNode = "__ROOT__"
)
Variables ¶
This section is empty.
Functions ¶
func IsVisualKey ¶
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) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface.
type Errors ¶
type Errors []*Error
Errors is a collection of Error
func (Errors) Errors ¶
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) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface.
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 ¶
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
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.
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)