go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/nodes/pkg/model/graph_store.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package model
     9  
    10  import (
    11  	"context"
    12  
    13  	"github.com/wcharczuk/go-incr"
    14  	"go.charczuk.com/projects/nodes/pkg/types"
    15  )
    16  
    17  // GraphStore is an interface that a graph store implementation must satisfy.
    18  //
    19  // Generally a graph store should implicitly control a single graph.
    20  type GraphStore interface {
    21  	Save(context.Context) (*types.GraphFull, error)
    22  	Load(context.Context, *types.GraphFull) (id incr.Identifier, err error)
    23  
    24  	Graph(context.Context) (*types.Graph, error)
    25  	Logs(ctx context.Context) (string, error)
    26  	SetViewport(context.Context, types.Viewport) error
    27  
    28  	Stabilize(ctx context.Context, parallel bool) (uint64, error)
    29  
    30  	AddNode(context.Context, *types.Node) (incr.Identifier, error)
    31  	RemoveNode(context.Context, incr.Identifier) (bool, error)
    32  	Nodes(context.Context) ([]types.Node, error)
    33  	Node(context.Context, incr.Identifier) (types.Node, bool, error)
    34  
    35  	PatchNodes(context.Context, types.PatchSet) error
    36  	PatchNode(context.Context, incr.Identifier, types.PatchSet) (bool, error)
    37  
    38  	NodeValue(context.Context, incr.Identifier) (any, bool, error)
    39  	NodeValues(context.Context, ...incr.Identifier) ([]types.NodeValue, error)
    40  	SetNodeValue(context.Context, incr.Identifier, any) (bool, error)
    41  
    42  	MarkNodeStale(context.Context, incr.Identifier) (bool, error)
    43  
    44  	Edges(context.Context) ([]types.Edge, error)
    45  	LinkInput(context.Context, types.Edge) error
    46  	UnlinkInput(context.Context, types.Edge) error
    47  
    48  	PatchNodeTable(context.Context, incr.Identifier, ...types.TableOp) (bool, error)
    49  }