Documentation
¶
Overview ¶
Package graph provides a generic, namespaced, directed graph store.
Kinds and relationship types are opaque consumer vocabulary. A store never assigns product meaning or authority to graph records.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("graph record not found") ErrConflict = errors.New("graph revision conflict") ErrIdempotency = errors.New("idempotency key reused with different transaction") ErrDanglingEdge = errors.New("edge endpoint does not exist") ErrIncidentEdges = errors.New("vertex has incident edges") ErrLimitRequired = errors.New("query limit must be positive") ErrSecretValue = errors.New("secret-like values are not allowed in graph attributes") ErrInvalidName = errors.New("invalid namespace, kind, or relationship name") ErrCursorExpired = errors.New("graph change cursor has expired; take a new snapshot") )
Functions ¶
func ValidateAttributes ¶
ValidateAttributes checks ordinary graph metadata before projection. It applies the same secret-marker and size rules as Store.Apply.
Types ¶
type Change ¶
type Change struct {
Cursor uint64 `json:"cursor"`
Namespace string `json:"namespace"`
Revision uint64 `json:"revision"`
Committed time.Time `json:"committed_at"`
Vertices []Vertex `json:"vertices,omitempty"`
Edges []Edge `json:"edges,omitempty"`
DeletedVertices []string `json:"deleted_vertices,omitempty"`
DeletedEdges []string `json:"deleted_edges,omitempty"`
}
type Edge ¶
type Edge struct {
Namespace string `json:"namespace"`
ID string `json:"id"`
From string `json:"from"`
To string `json:"to"`
Type string `json:"type"`
Revision uint64 `json:"revision"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Labels map[string]string `json:"labels,omitempty"`
Attributes map[string]any `json:"attributes,omitempty"`
Provenance Provenance `json:"provenance,omitempty"`
}
Edge is a directed relationship from From to To.
type Options ¶
Options controls how much replay history a store retains. Zero values use defaults of 4096 commits and 16 MiB of serialized changes. The latest commit is always kept, even when it alone exceeds MaxChangeBytes. Idempotency records older than the floor expire with their commit.
type Provenance ¶
type Provenance struct {
Source string `json:"source,omitempty"`
Operation string `json:"operation,omitempty"`
At time.Time `json:"at,omitempty"`
}
Provenance identifies the system or operation that produced a fact. It is descriptive metadata and grants no authority.
type Snapshot ¶
type Snapshot struct {
Namespace string `json:"namespace"`
Revision uint64 `json:"revision"`
Cursor uint64 `json:"cursor"`
// HistoryFloor is the newest cursor that is no longer available from Changes or Watch.
HistoryFloor uint64 `json:"history_floor,omitempty"`
Vertices []Vertex `json:"vertices"`
Edges []Edge `json:"edges"`
}
type Store ¶
type Store interface {
Register(Schema) error
Apply(context.Context, Transaction) (Commit, error)
GetVertex(context.Context, string, string) (Vertex, error)
GetEdge(context.Context, string, string) (Edge, error)
QueryVertices(context.Context, VertexQuery) ([]Vertex, error)
QueryEdges(context.Context, EdgeQuery) ([]Edge, error)
Traverse(context.Context, string, string, int, int) ([]Path, error)
Snapshot(context.Context, string) (Snapshot, error)
Changes(context.Context, string, uint64, int) ([]Change, error)
Watch(context.Context, string, uint64, int) (<-chan Change, error)
Close() error
}
func NewMemoryWithOptions ¶
type Transaction ¶
type Transaction struct {
Namespace string
IdempotencyKey string
ExpectedRevision *uint64
Vertices []Vertex
Edges []Edge
DeleteVertices []VertexRef
DeleteEdges []EdgeRef
DeleteIncidentEdges bool
}
Transaction is applied atomically within one namespace. A non-nil ExpectedRevision enables optimistic concurrency. DeleteVertices require DeleteIncidentEdges to explicitly detach incident edges.
type Validator ¶
type Validator func(View, Transaction) error
type Vertex ¶
type Vertex struct {
Namespace string `json:"namespace"`
ID string `json:"id"`
Kind string `json:"kind"`
Revision uint64 `json:"revision"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Labels map[string]string `json:"labels,omitempty"`
Attributes map[string]any `json:"attributes,omitempty"`
Provenance Provenance `json:"provenance,omitempty"`
}
Vertex is a generic typed graph record. ID is supplied by the consumer and should remain stable for the lifetime of the logical object.
type VertexQuery ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package supervisor runs generic local component processes and projects their observed lifecycle into a graph.
|
Package supervisor runs generic local component processes and projects their observed lifecycle into a graph. |
|
Package systemgraph projects CTX machine inventory, shell, and browser observations onto the public generic graph API.
|
Package systemgraph projects CTX machine inventory, shell, and browser observations onto the public generic graph API. |