Documentation ¶
Overview ¶
Package meshdb implements a storage.Database using any storage.MeshStorage instance.
Index ¶
- func New(db storage.MeshDataStore) storage.MeshDB
- func NewFromStorage(st storage.MeshStorage) storage.MeshDB
- type Database
- type MeshDBCloser
- type MeshDataStore
- type TestDB
- type ValidatingGraphStore
- func (g *ValidatingGraphStore) AddEdge(sourceNode, targetNode types.NodeID, edge graph.Edge[types.NodeID]) error
- func (g *ValidatingGraphStore) AddVertex(nodeID types.NodeID, node types.MeshNode, props graph.VertexProperties) error
- func (g *ValidatingGraphStore) Edge(sourceNode, targetNode types.NodeID) (graph.Edge[types.NodeID], error)
- func (g *ValidatingGraphStore) RemoveVertex(nodeID types.NodeID) error
- func (g *ValidatingGraphStore) Subscribe(ctx context.Context, fn storage.PeerSubscribeFunc) (context.CancelFunc, error)
- func (g *ValidatingGraphStore) UpdateEdge(sourceNode, targetNode types.NodeID, edge graph.Edge[types.NodeID]) error
- func (g *ValidatingGraphStore) Vertex(nodeID types.NodeID) (node types.MeshNode, props graph.VertexProperties, err error)
- type ValidatingMeshStateStore
- type ValidatingNetworkingStore
- func (v *ValidatingNetworkingStore) DeleteNetworkACL(ctx context.Context, name string) error
- func (v *ValidatingNetworkingStore) DeleteRoute(ctx context.Context, name string) error
- func (v *ValidatingNetworkingStore) GetNetworkACL(ctx context.Context, name string) (types.NetworkACL, error)
- func (v *ValidatingNetworkingStore) GetRoute(ctx context.Context, name string) (types.Route, error)
- func (v *ValidatingNetworkingStore) GetRoutesByCIDR(ctx context.Context, cidr netip.Prefix) (types.Routes, error)
- func (v *ValidatingNetworkingStore) GetRoutesByNode(ctx context.Context, nodeID types.NodeID) (types.Routes, error)
- func (v *ValidatingNetworkingStore) PutNetworkACL(ctx context.Context, acl types.NetworkACL) error
- func (v *ValidatingNetworkingStore) PutRoute(ctx context.Context, route types.Route) error
- type ValidatingPeerStore
- func (p *ValidatingPeerStore) Delete(ctx context.Context, id types.NodeID) error
- func (p *ValidatingPeerStore) Get(ctx context.Context, id types.NodeID) (types.MeshNode, error)
- func (p *ValidatingPeerStore) GetByPubKey(ctx context.Context, key crypto.PublicKey) (types.MeshNode, error)
- func (p *ValidatingPeerStore) GetEdge(ctx context.Context, source, target types.NodeID) (types.MeshEdge, error)
- func (p *ValidatingPeerStore) Graph() types.PeerGraph
- func (p *ValidatingPeerStore) List(ctx context.Context, filters ...storage.PeerFilter) ([]types.MeshNode, error)
- func (p *ValidatingPeerStore) ListIDs(ctx context.Context) ([]types.NodeID, error)
- func (p *ValidatingPeerStore) Put(ctx context.Context, node types.MeshNode) error
- func (p *ValidatingPeerStore) PutEdge(ctx context.Context, edge types.MeshEdge) error
- func (p *ValidatingPeerStore) RemoveEdge(ctx context.Context, from, to types.NodeID) error
- func (p *ValidatingPeerStore) Subscribe(ctx context.Context, fn storage.PeerSubscribeFunc) (context.CancelFunc, error)
- type ValidatingRBACStore
- func (v *ValidatingRBACStore) DeleteGroup(ctx context.Context, name string) error
- func (v *ValidatingRBACStore) DeleteRole(ctx context.Context, name string) error
- func (v *ValidatingRBACStore) DeleteRoleBinding(ctx context.Context, name string) error
- func (v *ValidatingRBACStore) GetGroup(ctx context.Context, name string) (types.Group, error)
- func (v *ValidatingRBACStore) GetRole(ctx context.Context, name string) (types.Role, error)
- func (v *ValidatingRBACStore) GetRoleBinding(ctx context.Context, name string) (types.RoleBinding, error)
- func (v *ValidatingRBACStore) ListNodeRoles(ctx context.Context, nodeID types.NodeID) (types.RolesList, error)
- func (v *ValidatingRBACStore) ListUserRoles(ctx context.Context, userID types.NodeID) (types.RolesList, error)
- func (v *ValidatingRBACStore) PutGroup(ctx context.Context, group types.Group) error
- func (v *ValidatingRBACStore) PutRole(ctx context.Context, role types.Role) error
- func (v *ValidatingRBACStore) PutRoleBinding(ctx context.Context, rolebinding types.RoleBinding) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(db storage.MeshDataStore) storage.MeshDB
New returns a new MeshDB instance using the given underlying MeshDataStore. Storage operations will be validated before being passed to the underlying MeshDataStore. If the underlying MeshDataStore already performs validation, this is redundant. Note that certain write operations will call into read methods to perform validation. So any locks used internally must be reentrant.
func NewFromStorage ¶ added in v0.11.0
func NewFromStorage(st storage.MeshStorage) storage.MeshDB
NewFromStorage creates a new MeshDB instance from the given MeshStorage. The same information applies as for New.
Types ¶
type Database ¶ added in v0.11.0
type Database struct {
// contains filtered or unexported fields
}
Database wraps a storage.MeshDataStore and automatically performs the necessary validation on all operations. Note that certain write operations will call into read methods to perform validation. So any locks used internally must be reentrant.
func (*Database) GraphStore ¶ added in v0.11.0
func (d *Database) GraphStore() storage.GraphStore
GraphStore returns the underlying storage.MeshDB's GraphStore instance with validators run before operations.
func (*Database) MeshState ¶ added in v0.11.0
MeshState returns the underlying storage.MeshDB's MeshState instance with validators run before operations.
func (*Database) Networking ¶ added in v0.11.0
func (d *Database) Networking() storage.Networking
Networking returns the underlying storage.MeshDB's Networking instance with validators run before operations.
type MeshDBCloser ¶
MeshDBCloser is a storage.MeshDB that can be closed.
type MeshDataStore ¶ added in v0.11.0
type MeshDataStore struct {
// contains filtered or unexported fields
}
MeshDataStore is a data store using an underlying MeshStorage instance.
func (*MeshDataStore) GraphStore ¶ added in v0.11.0
func (m *MeshDataStore) GraphStore() storage.GraphStore
GraphStore returns the underlying storage.MeshDB's GraphStore instance.
func (*MeshDataStore) MeshState ¶ added in v0.11.0
func (m *MeshDataStore) MeshState() storage.MeshState
MeshState returns the underlying storage.MeshDB's MeshState instance.
func (*MeshDataStore) Networking ¶ added in v0.11.0
func (m *MeshDataStore) Networking() storage.Networking
Networking returns the underlying storage.MeshDB's Networking instance.
func (*MeshDataStore) RBAC ¶ added in v0.11.0
func (m *MeshDataStore) RBAC() storage.RBAC
RBAC returns the underlying storage.MeshDB's RBAC instance.
type ValidatingGraphStore ¶ added in v0.11.0
type ValidatingGraphStore struct {
storage.GraphStore
}
ValidatingGraphStore wraps a types.PeerGraphStore and automatically performs the necessary validation on all operations.
func (*ValidatingGraphStore) AddEdge ¶ added in v0.11.0
func (g *ValidatingGraphStore) AddEdge(sourceNode, targetNode types.NodeID, edge graph.Edge[types.NodeID]) error
AddEdge should add an edge between the vertices with the given source and target hashes.
If either vertex doesn't exit, ErrVertexNotFound should be returned for the respective vertex. If the edge already exists, ErrEdgeAlreadyExists should be returned.
func (*ValidatingGraphStore) AddVertex ¶ added in v0.11.0
func (g *ValidatingGraphStore) AddVertex(nodeID types.NodeID, node types.MeshNode, props graph.VertexProperties) error
AddVertex should add the given vertex with the given hash value and vertex properties to the graph. If the vertex already exists, it is up to you whether ErrVertexAlreadyExists or no error should be returned.
func (*ValidatingGraphStore) Edge ¶ added in v0.11.0
func (g *ValidatingGraphStore) Edge(sourceNode, targetNode types.NodeID) (graph.Edge[types.NodeID], error)
Edge should return the edge joining the vertices with the given hash values. It should exclusively look for an edge between the source and the target vertex, not vice versa. The graph implementation does this for undirected graphs itself.
Note that unlike Graph.Edge, this function is supposed to return an Edge[K], i.e. an edge that only contains the vertex hashes instead of the vertices themselves.
If the edge doesn't exist, ErrEdgeNotFound should be returned.
func (*ValidatingGraphStore) RemoveVertex ¶ added in v0.11.0
func (g *ValidatingGraphStore) RemoveVertex(nodeID types.NodeID) error
RemoveVertex should remove the vertex with the given hash value. If the vertex doesn't exist, ErrVertexNotFound should be returned. If the vertex has edges to other vertices, ErrVertexHasEdges should be returned.
func (*ValidatingGraphStore) Subscribe ¶ added in v0.11.0
func (g *ValidatingGraphStore) Subscribe(ctx context.Context, fn storage.PeerSubscribeFunc) (context.CancelFunc, error)
Subscribe subscribes to node and edge changes from the underlying graph storage.
func (*ValidatingGraphStore) UpdateEdge ¶ added in v0.11.0
func (g *ValidatingGraphStore) UpdateEdge(sourceNode, targetNode types.NodeID, edge graph.Edge[types.NodeID]) error
UpdateEdge should update the edge between the given vertices with the data of the given Edge instance. If the edge doesn't exist, ErrEdgeNotFound should be returned.
func (*ValidatingGraphStore) Vertex ¶ added in v0.11.0
func (g *ValidatingGraphStore) Vertex(nodeID types.NodeID) (node types.MeshNode, props graph.VertexProperties, err error)
Vertex should return the vertex and vertex properties with the given hash value. If the vertex doesn't exist, ErrVertexNotFound should be returned.
type ValidatingMeshStateStore ¶ added in v0.11.0
ValidatingMeshStateStore wraps a storage.MeshState and automatically performs the necessary validation on all operations.
func (*ValidatingMeshStateStore) GetMeshState ¶ added in v0.12.0
func (v *ValidatingMeshStateStore) GetMeshState(ctx context.Context) (types.NetworkState, error)
GetMeshState returns the mesh state.
func (*ValidatingMeshStateStore) SetMeshState ¶ added in v0.13.12
func (v *ValidatingMeshStateStore) SetMeshState(ctx context.Context, state types.NetworkState) error
SetMeshDomain sets the mesh domain.
type ValidatingNetworkingStore ¶ added in v0.11.0
type ValidatingNetworkingStore struct {
storage.Networking
}
ValidatingNetworkingStore wraps a storage.Networking and automatically performs the necessary validation on all operations.
func (*ValidatingNetworkingStore) DeleteNetworkACL ¶ added in v0.11.0
func (v *ValidatingNetworkingStore) DeleteNetworkACL(ctx context.Context, name string) error
DeleteNetworkACL deletes a NetworkACL by name.
func (*ValidatingNetworkingStore) DeleteRoute ¶ added in v0.11.0
func (v *ValidatingNetworkingStore) DeleteRoute(ctx context.Context, name string) error
DeleteRoute deletes a Route by name.
func (*ValidatingNetworkingStore) GetNetworkACL ¶ added in v0.11.0
func (v *ValidatingNetworkingStore) GetNetworkACL(ctx context.Context, name string) (types.NetworkACL, error)
GetNetworkACL returns a NetworkACL by name.
func (*ValidatingNetworkingStore) GetRoutesByCIDR ¶ added in v0.11.0
func (v *ValidatingNetworkingStore) GetRoutesByCIDR(ctx context.Context, cidr netip.Prefix) (types.Routes, error)
GetRoutesByCIDR returns a list of Routes for a given CIDR.
func (*ValidatingNetworkingStore) GetRoutesByNode ¶ added in v0.11.0
func (v *ValidatingNetworkingStore) GetRoutesByNode(ctx context.Context, nodeID types.NodeID) (types.Routes, error)
GetRoutesByNode returns a list of Routes for a given Node.
func (*ValidatingNetworkingStore) PutNetworkACL ¶ added in v0.11.0
func (v *ValidatingNetworkingStore) PutNetworkACL(ctx context.Context, acl types.NetworkACL) error
PutNetworkACL creates or updates a NetworkACL.
type ValidatingPeerStore ¶ added in v0.11.0
type ValidatingPeerStore struct {
// contains filtered or unexported fields
}
ValidatingPeerStore wraps graph store implementation with a simpler to use peer store interface.
func (*ValidatingPeerStore) Delete ¶ added in v0.11.0
Delete removes the node by first removing any edges it is a part of and then removing it from the graph.
func (*ValidatingPeerStore) Get ¶ added in v0.11.0
Get validates the node ID and then retrieves it from the underlying graph storage.
func (*ValidatingPeerStore) GetByPubKey ¶ added in v0.11.0
func (p *ValidatingPeerStore) GetByPubKey(ctx context.Context, key crypto.PublicKey) (types.MeshNode, error)
GetByPubKey gets a node by their public key.
func (*ValidatingPeerStore) GetEdge ¶ added in v0.11.0
func (p *ValidatingPeerStore) GetEdge(ctx context.Context, source, target types.NodeID) (types.MeshEdge, error)
GetEdge returns the edge between the given nodes by first validating the nodes and then calling the underlying storage.Peers GetEdge method.
func (*ValidatingPeerStore) Graph ¶ added in v0.11.0
func (p *ValidatingPeerStore) Graph() types.PeerGraph
Graph returns the underlying graph.
func (*ValidatingPeerStore) List ¶ added in v0.11.0
func (p *ValidatingPeerStore) List(ctx context.Context, filters ...storage.PeerFilter) ([]types.MeshNode, error)
List returns all nodes in the graph.
func (*ValidatingPeerStore) Put ¶ added in v0.11.0
Put validates the node and then saves it to the underlying graph storage.
func (*ValidatingPeerStore) PutEdge ¶ added in v0.11.0
PutEdge validates the edge and then calls the underlying storage.Peers PutEdge method.
func (*ValidatingPeerStore) RemoveEdge ¶ added in v0.11.0
RemoveEdge removes the edge between the given nodes by first validating the nodes and then calling the underlying storage.Peers RemoveEdge method.
func (*ValidatingPeerStore) Subscribe ¶ added in v0.11.0
func (p *ValidatingPeerStore) Subscribe(ctx context.Context, fn storage.PeerSubscribeFunc) (context.CancelFunc, error)
Subscribe subscribe to node and edge changes from the underlying graph storage.
type ValidatingRBACStore ¶ added in v0.11.0
ValidatingRBACStore wraps a storage.RBAC and automatically performs the necessary validation on all operations.
func (*ValidatingRBACStore) DeleteGroup ¶ added in v0.11.0
func (v *ValidatingRBACStore) DeleteGroup(ctx context.Context, name string) error
DeleteGroup deletes a group by name.
func (*ValidatingRBACStore) DeleteRole ¶ added in v0.11.0
func (v *ValidatingRBACStore) DeleteRole(ctx context.Context, name string) error
DeleteRole deletes a role by name.
func (*ValidatingRBACStore) DeleteRoleBinding ¶ added in v0.11.0
func (v *ValidatingRBACStore) DeleteRoleBinding(ctx context.Context, name string) error
DeleteRoleBinding deletes a rolebinding by name.
func (*ValidatingRBACStore) GetRoleBinding ¶ added in v0.11.0
func (v *ValidatingRBACStore) GetRoleBinding(ctx context.Context, name string) (types.RoleBinding, error)
GetRoleBinding returns a rolebinding by name.
func (*ValidatingRBACStore) ListNodeRoles ¶ added in v0.11.0
func (v *ValidatingRBACStore) ListNodeRoles(ctx context.Context, nodeID types.NodeID) (types.RolesList, error)
ListNodeRoles returns a list of all roles for a node.
func (*ValidatingRBACStore) ListUserRoles ¶ added in v0.11.0
func (v *ValidatingRBACStore) ListUserRoles(ctx context.Context, userID types.NodeID) (types.RolesList, error)
ListUserRoles returns a list of all roles for a user.
func (*ValidatingRBACStore) PutRoleBinding ¶ added in v0.11.0
func (v *ValidatingRBACStore) PutRoleBinding(ctx context.Context, rolebinding types.RoleBinding) error
PutRoleBinding creates or updates a rolebinding.
Directories ¶
Path | Synopsis |
---|---|
Package graph implements a graph data structure for the mesh network.
|
Package graph implements a graph data structure for the mesh network. |
Package networking contains interfaces to the database models for Network ACLs and Routes.
|
Package networking contains interfaces to the database models for Network ACLs and Routes. |
Package rbac contains interfaces to the database models for RBAC.
|
Package rbac contains interfaces to the database models for RBAC. |
Package state provides an interface for querying mesh state.
|
Package state provides an interface for querying mesh state. |