Help us shape the future of Go! Take the 2026 Go Developer Survey

graph

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConflict = errors.New("graph: conflict")

ErrConflict indicates a uniqueness violation (e.g. duplicate repo:// URI).

View Source
var ErrNotFound = errors.New("graph: not found")

ErrNotFound indicates the requested node or edge does not exist.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	From  NodeID            `json:"from"`
	To    NodeID            `json:"to"`
	Type  EdgeType          `json:"type"`
	Props map[string]string `json:"props,omitempty"`
}

Edge connects two nodes with a typed relationship.

type EdgeType

type EdgeType string

EdgeType categorizes relationships between nodes.

type Node

type Node struct {
	ID    NodeID            `json:"id"`
	Kind  string            `json:"kind"`
	Name  string            `json:"name,omitempty"`
	Path  string            `json:"path,omitempty"`
	Props map[string]string `json:"props,omitempty"`
}

Node is a vertex in the code graph.

type NodeID

type NodeID string

NodeID uniquely identifies a node in the graph.

type Store

type Store interface {
	Close() error

	PutNode(node Node) error
	GetNode(id NodeID) (Node, error)
	DeleteNode(id NodeID) error

	PutEdge(edge Edge) error
	DeleteEdge(from NodeID, to NodeID, edgeType EdgeType) error

	// OutEdges returns edges leaving from. If edgeType is non-empty, results are filtered.
	OutEdges(from NodeID, edgeType EdgeType) ([]Edge, error)

	// InEdges returns edges entering to. If edgeType is non-empty, results are filtered.
	InEdges(to NodeID, edgeType EdgeType) ([]Edge, error)

	// ForEachNode invokes fn for every node. Iteration stops early if fn returns false.
	ForEachNode(fn func(Node) bool) error

	// GetNodeByURI resolves a canonical repo:// URI via the secondary unique index.
	// Nodes without a URI are not findable this way.
	GetNodeByURI(repoURI string) (Node, error)
}

Store persists graph nodes and typed edges.

Directories

Path Synopsis
Package snapshot streams graph shards as versioned NDJSON (SYN-16).
Package snapshot streams graph shards as versioned NDJSON (SYN-16).

Jump to

Keyboard shortcuts

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