Documentation
¶
Overview ¶
Package wikistore provides a graph store over the memory_nodes / memory_edges tables. It defines the Store interface in terms of plain Go POJOs (migrate.NodeSpec / EdgeSpec) so that the graph runtime never touches sqlc or driver-specific types. The PostgreSQL implementation wraps the sqlc-generated queries.
Index ¶
- Variables
- type PostgresStore
- func (s *PostgresStore) CountEdges(ctx context.Context, botID string) (int, error)
- func (s *PostgresStore) CountNodes(ctx context.Context, botID string) (int, error)
- func (s *PostgresStore) DeleteAllEdges(ctx context.Context, botID string) error
- func (s *PostgresStore) DeleteAllNodes(ctx context.Context, botID string) error
- func (s *PostgresStore) DeleteEdgesForNode(ctx context.Context, botID, nodeID string) error
- func (s *PostgresStore) DeleteNode(ctx context.Context, botID, nodeID string) error
- func (s *PostgresStore) GetNode(ctx context.Context, botID, nodeID string) (migrate.NodeSpec, error)
- func (s *PostgresStore) ListEdges(ctx context.Context, botID string) ([]migrate.EdgeSpec, error)
- func (s *PostgresStore) ListNodes(ctx context.Context, botID string) ([]migrate.NodeSpec, error)
- func (s *PostgresStore) ListNodesByLayer(ctx context.Context, botID string, layer migrate.MemoryLayer) ([]migrate.NodeSpec, error)
- func (s *PostgresStore) RebuildDerivedEdges(ctx context.Context, botID string) (int, error)
- func (s *PostgresStore) UpsertEdges(ctx context.Context, edges []migrate.EdgeSpec) error
- func (s *PostgresStore) UpsertNode(ctx context.Context, node migrate.NodeSpec) (migrate.NodeSpec, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrNodeNotFound = errNodeNotFound{}
ErrNodeNotFound is returned by GetNode when no node matches the id.
Functions ¶
This section is empty.
Types ¶
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore implements Store over the PostgreSQL memory_wiki tables.
func NewPostgres ¶
func NewPostgres(q *dbsqlc.Queries) *PostgresStore
NewPostgres returns a Store backed by the PostgreSQL sqlc Queries.
func (*PostgresStore) CountEdges ¶
func (*PostgresStore) CountNodes ¶
func (*PostgresStore) DeleteAllEdges ¶
func (s *PostgresStore) DeleteAllEdges(ctx context.Context, botID string) error
func (*PostgresStore) DeleteAllNodes ¶
func (s *PostgresStore) DeleteAllNodes(ctx context.Context, botID string) error
func (*PostgresStore) DeleteEdgesForNode ¶
func (s *PostgresStore) DeleteEdgesForNode(ctx context.Context, botID, nodeID string) error
func (*PostgresStore) DeleteNode ¶
func (s *PostgresStore) DeleteNode(ctx context.Context, botID, nodeID string) error
func (*PostgresStore) ListNodesByLayer ¶
func (s *PostgresStore) ListNodesByLayer(ctx context.Context, botID string, layer migrate.MemoryLayer) ([]migrate.NodeSpec, error)
func (*PostgresStore) RebuildDerivedEdges ¶
func (*PostgresStore) UpsertEdges ¶
func (*PostgresStore) UpsertNode ¶
type Store ¶
type Store interface {
// UpsertNode inserts or updates a single node by id (idempotent on conflict).
UpsertNode(ctx context.Context, node migrate.NodeSpec) (migrate.NodeSpec, error)
// GetNode returns one node by id, or ErrNodeNotFound.
GetNode(ctx context.Context, botID, nodeID string) (migrate.NodeSpec, error)
// ListNodes returns every node for a bot in captured_at ascending order.
ListNodes(ctx context.Context, botID string) ([]migrate.NodeSpec, error)
// ListNodesByLayer returns nodes for a bot filtered by layer.
ListNodesByLayer(ctx context.Context, botID string, layer migrate.MemoryLayer) ([]migrate.NodeSpec, error)
// DeleteNode removes a node (and its incident edges via ON DELETE CASCADE
// at the SQL level for bot-scoped rows, plus explicit edge cleanup here).
DeleteNode(ctx context.Context, botID, nodeID string) error
// DeleteAllNodes removes every node for a bot (edges removed by the caller
// or DB cascade).
DeleteAllNodes(ctx context.Context, botID string) error
// CountNodes returns the node count for a bot.
CountNodes(ctx context.Context, botID string) (int, error)
// UpsertEdges inserts or updates (on conflict) a batch of edges.
UpsertEdges(ctx context.Context, edges []migrate.EdgeSpec) error
// ListEdges returns every edge for a bot.
ListEdges(ctx context.Context, botID string) ([]migrate.EdgeSpec, error)
// DeleteEdgesForNode removes all edges incident to a node (src or dst).
DeleteEdgesForNode(ctx context.Context, botID, nodeID string) error
// DeleteAllEdges removes every edge for a bot.
DeleteAllEdges(ctx context.Context, botID string) error
// CountEdges returns the edge count for a bot.
CountEdges(ctx context.Context, botID string) (int, error)
// RebuildDerivedEdges recomputes same_profile / same_topic / same_day / refs
// edges for a bot from its current nodes, replacing any prior derived edges.
// Returns the number of edges written.
RebuildDerivedEdges(ctx context.Context, botID string) (int, error)
}
Store is the backend-agnostic contract over the memory wiki tables. All methods are scoped to a single bot_id. NodeSpec/EdgeSpec come from the migrate package and carry no driver-specific types.