Documentation ¶
Index ¶
Constants ¶
const ( ECONFLICT = "conflict" EINTERNAL = "internal" EINVALID = "invalid" ENOTFOUND = "not_found" ENOTIMPLEMENTED = "not_implemented" EUNAUTHORIZED = "unauthorized" )
API error codes.
Variables ¶
This section is empty.
Functions ¶
func ErrorCode ¶
ErrorCode unwraps an application error and returns its code. Non-application errors always return EINTERNAL.
func ErrorMessage ¶
ErrorMessage unwraps an application error and returns its message. Non-application errors always return "Internal error".
Types ¶
type Edge ¶
type Edge struct { // UID is edge UUID. UID string `json:"uid,omitempty"` // Source is an UID of the edge source node. Source string `json:"source"` // Target is an UID of the edge target node. Target string `json:"target"` // Weight is the edge weight. Weight float64 `json:"weight"` // Label is the edge label Label string `json:"label"` // Attrs are edge attributes Attrs map[string]interface{} `json:"attributes,omitempty"` // Timestamps for graph creation & last update. CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
Edge is an edge between two graph nodes.
type EdgeFilter ¶
type EdgeFilter struct { // Filtering fields. // Source filters edges starting in Source UID. Source *string `json:"source"` // Target filters edges ending in Target UID. Target *string `json:"target"` Label *string `json:"label"` // Restrict to subset of range. Offset int `json:"offset"` Limit int `json:"limit"` }
EdgeFilter represents a filter used by FindEdges().
type EdgeService ¶
type EdgeService interface { // CreateEdge creates a new edge. CreateEdge(ctx context.Context, uid string, e *Edge) error // FindEdgeByUID returns a single edge with the given uid. FindEdgeByUID(ctx context.Context, guid, euid string) (*Edge, error) // FindEdges returns all edges matching the filter. // It also returns a count of total matching edges which may differ from // the number of returned edges if the Limit field is set. FindEdges(ctx context.Context, uid string, filter EdgeFilter) ([]*Edge, int, error) // UpdateEdgeBetween updates an edge between two nodes. UpdateEdgeBetween(ctx context.Context, uid string, source, target string, update EdgeUpdate) (*Edge, error) // DeleteEdge permanently removes an edge by UID. DeleteEdge(ctx context.Context, guid, euid string) error // DeleteEdgeBetween permanently deletes all edges between two nodes. DeleteEdgeBetween(ctx context.Context, uid string, source, target string) error }
EdgeService represents a service for managing Edges.
type EdgeUpdate ¶
type EdgeUpdate struct { Weight *float64 `json:"weight"` Label *string `json:"label"` Attrs map[string]interface{} `json:"attributes,omitempty"` }
EdgeUpdate represents a set of fields to update on an edge.
type Error ¶
type Error struct { // Machine-readable error code. Code string // Human-readable error message. Message string }
Error represents an application-specific error. Application errors can be unwrapped by the caller to extract out the code & message.
Any non-application error (such as a disk error) should be reported as an EINTERNAL error and the human user should only see "Internal error" as the message. These low-level internal error details should only be logged and reported to the operator of the application (not the end user).
type Graph ¶
type Graph struct { // UID is graph UUID. UID string `json:"uid,omitempty"` // Nodes is the node count. Nodes int `json:"nodes"` // Edge is the edge count. Edges int `json:"edges"` // Label is graph label. Label *string `json:"label,omitempty"` // Attrs are graph attributes. Attrs map[string]interface{} `json:"attributes,omitempty"` // Timestamps for graph creation & last update. CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
Graph contains nodes connected by edges.
type GraphFilter ¶
type GraphFilter struct { // Filtering fields. UID *string `json:"uid"` Label *string `json:"label"` // Restrict to subset of range. Offset int `json:"offset"` Limit int `json:"limit"` }
GraphFilter represents a filter used by FindGraphs().
type GraphService ¶
type GraphService interface { // CreateGraph creates a new graph. CreateGraph(ctx context.Context, g *Graph) error // FindGraphByUID returns a single graph with the given uid. FindGraphByUID(ctx context.Context, uid string) (*Graph, error) // FindGraphs returns all graphs matching the filter. // It also returns a count of total matching graphs which may differ from // the number of returned graphs if the Limit field is set. FindGraphs(ctx context.Context, filter GraphFilter) ([]*Graph, int, error) // UpdateGraph updates an existing graph by UID. UpdateGraph(ctx context.Context, uid string, update GraphUpdate) (*Graph, error) // DeleteGraph permanently removes a graph by UID. DeleteGraph(ctx context.Context, uid string) error }
GraphService represents a service for managing Graphs.
type GraphUpdate ¶
type GraphUpdate struct { Label *string `json:"label"` Attrs map[string]interface{} `json:"attributes,omitempty"` }
GraphUpdate represents a set of fields to update on a graph.
type Node ¶
type Node struct { // ID is node ID. ID int64 `json:"id"` // UID is node UUID. UID string `json:"uid,omitempty"` // DegOut is the count of outgoing edges. DegOut int `json:"deg_out"` // DegIn is the count of incoming edges. DegIn int `json:"deg_in"` // Label is node label Label *string `json:"label"` // Attrs are node attributes Attrs map[string]interface{} `json:"attributes,omitempty"` // Timestamps for graph creation & last update. CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
Node is a graph node.
type NodeFilter ¶
type NodeFilter struct { // Filtering fields. ID *int64 `json:"id"` UID *string `json:"uid"` Label *string `json:"label"` // Target gets all nodes that // can reach this node. Target *string `json:"target"` // Source gets all nodes // reachable from this node. Source *string `json:"source"` // Restrict to subset of range. Offset int `json:"offset"` Limit int `json:"limit"` }
NodeFilter represents a filter used by FindNodes().
type NodeService ¶
type NodeService interface { // CreateNode creates a new node. CreateNode(ctx context.Context, uid string, n *Node) error // FindNodeByID returns a single node with the given id. FindNodeByID(ctx context.Context, uid string, id int64) (*Node, error) // FindNodeByUID returns a single node with the given uid. FindNodeByUID(ctx context.Context, guid, nuid string) (*Node, error) // FindNodes returns all nodes matching the filter. // It also returns a count of total matching nodes which may differ from // the number of returned nodes if the Limit field is set. FindNodes(ctx context.Context, uid string, filter NodeFilter) ([]*Node, int, error) // UpdateNode updates an existing node by ID. UpdateNode(ctx context.Context, uid string, id int64, update NodeUpdate) (*Node, error) // DeleteNodeByUID permanently removes a node by UID. // It automatically removes removed node's incoming and outgoing edges. DeleteNodeByUID(ctx context.Context, guid, nuid string) error // DeleteNodeByID permanently removes a node by ID. // It automatically removes removed node's incoming and outgoing edges. DeleteNodeByID(ctx context.Context, uid string, id int64) error }
NodeService represents a service for managing graph nodes.
type NodeUpdate ¶
type NodeUpdate struct { Label *string `json:"label"` Attrs map[string]interface{} `json:"attributes,omitempty"` }
NodeUpdate represents a set of fields to update on a node.