Documentation ¶
Index ¶
- Constants
- Variables
- func StringPtr(s string) *string
- type DB
- type EdgeService
- func (es *EdgeService) CreateEdge(ctx context.Context, uid string, e *api.Edge) error
- func (es *EdgeService) DeleteEdge(ctx context.Context, guid, euid string) error
- func (es *EdgeService) DeleteEdgeBetween(ctx context.Context, guid string, source, target string) error
- func (es *EdgeService) FindEdgeByUID(ctx context.Context, guid, euid string) (*api.Edge, error)
- func (es *EdgeService) FindEdges(ctx context.Context, guid string, filter api.EdgeFilter) ([]*api.Edge, int, error)
- func (es *EdgeService) UpdateEdgeBetween(ctx context.Context, guid string, source, target string, update api.EdgeUpdate) (*api.Edge, error)
- type GraphService
- func (gs *GraphService) CreateGraph(ctx context.Context, g *api.Graph) error
- func (gs *GraphService) DeleteGraph(ctx context.Context, uid string) error
- func (gs *GraphService) FindGraphByUID(ctx context.Context, uid string) (*api.Graph, error)
- func (gs *GraphService) FindGraphs(ctx context.Context, filter api.GraphFilter) ([]*api.Graph, int, error)
- func (gs *GraphService) UpdateGraph(ctx context.Context, uid string, update api.GraphUpdate) (*api.Graph, error)
- type NodeService
- func (ns *NodeService) CreateNode(ctx context.Context, uid string, n *api.Node) error
- func (ns *NodeService) DeleteNodeByID(ctx context.Context, uid string, id int64) error
- func (ns *NodeService) DeleteNodeByUID(ctx context.Context, guid, nuid string) error
- func (ns *NodeService) FindNodeByID(ctx context.Context, uid string, id int64) (*api.Node, error)
- func (ns *NodeService) FindNodeByUID(ctx context.Context, guid, nuid string) (*api.Node, error)
- func (ns *NodeService) FindNodes(ctx context.Context, uid string, filter api.NodeFilter) ([]*api.Node, int, error)
- func (ns *NodeService) UpdateNode(ctx context.Context, uid string, id int64, update api.NodeUpdate) (*api.Node, error)
- type Tx
- func (t *Tx) CreateEdge(ctx context.Context, uid string, e *api.Edge) error
- func (t *Tx) CreateGraph(ctx context.Context, g *api.Graph) error
- func (t *Tx) CreateNode(ctx context.Context, uid string, n *api.Node) error
- func (t *Tx) DeleteEdge(ctx context.Context, guid, euid string) error
- func (t *Tx) DeleteEdgeBetween(ctx context.Context, uid string, source, target string) error
- func (t *Tx) DeleteGraph(ctx context.Context, uid string) error
- func (t *Tx) DeleteNodeByID(ctx context.Context, uid string, id int64) error
- func (t *Tx) DeleteNodeByUID(ctx context.Context, guid, nuid string) error
- func (t *Tx) FindEdgeByUID(ctx context.Context, guid, euid string) (*TxEdge, error)
- func (t *Tx) FindEdges(ctx context.Context, uid string, filter api.EdgeFilter) ([]*TxEdge, int, error)
- func (t *Tx) FindGraphByUID(ctx context.Context, uid string) (*memory.Graph, error)
- func (t *Tx) FindGraphs(ctx context.Context, filter api.GraphFilter) ([]*memory.Graph, int, error)
- func (t *Tx) FindNodeByID(ctx context.Context, uid string, id int64) (*TxNode, error)
- func (t *Tx) FindNodeByUID(ctx context.Context, guid, uid string) (*TxNode, error)
- func (t *Tx) FindNodes(ctx context.Context, uid string, filter api.NodeFilter) ([]*TxNode, int, error)
- func (t *Tx) UpdateEdgeBetween(ctx context.Context, uid string, source, target string, update api.EdgeUpdate) (*TxEdge, error)
- func (t *Tx) UpdateGraph(ctx context.Context, uid string, update api.GraphUpdate) (*memory.Graph, error)
- func (t *Tx) UpdateNode(ctx context.Context, uid string, id int64, update api.NodeUpdate) (*TxNode, error)
- type TxEdge
- type TxNode
Constants ¶
const ( // DefaultLabel is the default graph label. DefaultLabel = "MemoryGraph" // DSN is the in-memory data source name. DSN = ":memory:" )
Variables ¶
var ( // ErrDBClosed is returned if attempting a transaction on closed DB. ErrDBClosed = errors.New("ErrDBClosed") )
Functions ¶
Types ¶
type DB ¶
type DB struct { // Datasource name. DSN string // Closed flag for DB operations. Closed bool *sync.RWMutex // contains filtered or unexported fields }
DB is an in-memory graph store.
func NewDB ¶
NewDB returns a new instance of DB associated with the given datasource name. NOTE: dsn is either ":memory:" or a path to a directory that stores graphs.
type EdgeService ¶
type EdgeService struct {
// contains filtered or unexported fields
}
EdgeService lets you manage graph edges.
func NewEdgeService ¶
func NewEdgeService(db *DB) (*EdgeService, error)
NewEdgeService creates an instance of EdgeService and returns it. Nodes managed by the node service belong to the graph with the given uid.
func (*EdgeService) CreateEdge ¶
CreateEdge creates a new edge.
func (*EdgeService) DeleteEdge ¶
func (es *EdgeService) DeleteEdge(ctx context.Context, guid, euid string) error
DeleteEdge permanently removes an edge by UID.
func (*EdgeService) DeleteEdgeBetween ¶
func (es *EdgeService) DeleteEdgeBetween(ctx context.Context, guid string, source, target string) error
DeleteEdgeBetween permanently deletes all edges between source and target nodes.
func (*EdgeService) FindEdgeByUID ¶
FindEdgeByUID returns a single edge with the given id.
func (*EdgeService) FindEdges ¶
func (es *EdgeService) FindEdges(ctx context.Context, guid string, filter api.EdgeFilter) ([]*api.Edge, int, 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.
func (*EdgeService) UpdateEdgeBetween ¶
func (es *EdgeService) UpdateEdgeBetween(ctx context.Context, guid string, source, target string, update api.EdgeUpdate) (*api.Edge, error)
UpdateEdgeBetween updates an edge between two nodes.
type GraphService ¶
type GraphService struct {
// contains filtered or unexported fields
}
GraphService lets you manage graphs.
func NewGraphService ¶
func NewGraphService(db *DB) (*GraphService, error)
NewGraphService creates an instance of GraphService and returns it.
func (*GraphService) CreateGraph ¶
CreateGraph creates a new graph.
func (*GraphService) DeleteGraph ¶
func (gs *GraphService) DeleteGraph(ctx context.Context, uid string) error
DeleteGraph permanently removes a graph by ID.
func (*GraphService) FindGraphByUID ¶
FindGraphByUID returns a single graph with the given uid.
func (*GraphService) FindGraphs ¶
func (gs *GraphService) FindGraphs(ctx context.Context, filter api.GraphFilter) ([]*api.Graph, int, 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.
func (*GraphService) UpdateGraph ¶
func (gs *GraphService) UpdateGraph(ctx context.Context, uid string, update api.GraphUpdate) (*api.Graph, error)
UpdateGraph updates an existing graph by ID.
type NodeService ¶
type NodeService struct {
// contains filtered or unexported fields
}
NodeService manages graph nodes.
func NewNodeService ¶
func NewNodeService(db *DB) (*NodeService, error)
NewNodeService creates an instance of NodeService and returns it. Nodes managed by the node service belong to the graph with the given uid.
func (*NodeService) CreateNode ¶
CreateNode creates a new node.
func (*NodeService) DeleteNodeByID ¶
DeleteNodeByID permanently removes a node by ID. It automatically removes removed node's incoming and outgoing edges.
func (*NodeService) DeleteNodeByUID ¶
func (ns *NodeService) DeleteNodeByUID(ctx context.Context, guid, nuid string) error
DeleteNodeByUID permanently removes a node by UID. It automatically removes removed node's incoming and outgoing edges.
func (*NodeService) FindNodeByID ¶
FindNodeByID returns a single node with the given id.
func (*NodeService) FindNodeByUID ¶
FindNodeByID returns a single node with the given uid.
func (*NodeService) FindNodes ¶
func (ns *NodeService) FindNodes(ctx context.Context, uid string, filter api.NodeFilter) ([]*api.Node, int, 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.
func (*NodeService) UpdateNode ¶
func (ns *NodeService) UpdateNode(ctx context.Context, uid string, id int64, update api.NodeUpdate) (*api.Node, error)
UpdateNode updates an existing node by ID.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx wraps DB to provide graph CRUD operations.
func (*Tx) CreateEdge ¶
CreateEdge adds a new node to graph. nolint:revive
func (*Tx) CreateGraph ¶
CreateGraph creates a new graph and returns it. nolint:revive
func (*Tx) CreateNode ¶
CreateNode adds a new node to graph. nolint:revive
func (*Tx) DeleteEdge ¶
DeleteEdge deletes edge with the given uid from graph. nolint:revive
func (*Tx) DeleteEdgeBetween ¶
DeleteEdgeBetween deletes all edges between source and target nodes. nolint:revive
func (*Tx) DeleteGraph ¶
DeleteGraph deletes graph from db. nolint:revive
func (*Tx) DeleteNodeByID ¶
DeleteNode deletes node from graph. nolint:revive
func (*Tx) DeleteNodeByUID ¶
DeleteNode deletes node from graph.
func (*Tx) FindEdgeByUID ¶
FindEdgeByUID returns edge with the given UID. It returns error if the edge with the given uid could not be found.
func (*Tx) FindEdges ¶
func (t *Tx) FindEdges(ctx context.Context, uid string, filter api.EdgeFilter) ([]*TxEdge, int, error)
FindEdges returns all graph nodes matching the filter.
func (*Tx) FindGraphByUID ¶
FindGraphByUID returns graph with the given UID. It returns error if the graph with the given uid could not be found. nolint:revive
func (*Tx) FindGraphs ¶
FindGraphs returns all graphs matching the filter. nolint:revive
func (*Tx) FindNodeByID ¶
FindNodeByID returns node with the given ID. It returns error if the node with the given id could not be found.
func (*Tx) FindNodeByUID ¶
FindNodeByUID returns node with the given UID. It returns error if the node with the given uid could not be found.
func (*Tx) FindNodes ¶
func (t *Tx) FindNodes(ctx context.Context, uid string, filter api.NodeFilter) ([]*TxNode, int, error)
FindNodes returns all graph nodes matching the filter.
func (*Tx) UpdateEdgeBetween ¶
func (t *Tx) UpdateEdgeBetween(ctx context.Context, uid string, source, target string, update api.EdgeUpdate) (*TxEdge, error)
UpdateEdgeBetween updates edge between two nodes. nolint:revive