meshdb

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

Package meshdb implements a storage.Database using any storage.MeshStorage instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

func (d *Database) MeshState() storage.MeshState

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.

func (*Database) Peers added in v0.11.0

func (d *Database) Peers() storage.Peers

Peers returns the underlying storage.MeshDB's Peers instance with validators run before operations.

func (*Database) RBAC added in v0.11.0

func (d *Database) RBAC() storage.RBAC

RBAC returns the underlying storage.MeshDB's RBAC instance with validators run before operations.

type MeshDBCloser

type MeshDBCloser interface {
	storage.MeshDB
	io.Closer
}

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 TestDB

type TestDB struct {
	storage.MeshDB
	io.Closer
}

func NewTestDB

func NewTestDB() *TestDB

NewTestDB returns a new in-memory storage.Database instance for testing.

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

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

type ValidatingMeshStateStore struct {
	storage.MeshState
}

ValidatingMeshStateStore wraps a storage.MeshState and automatically performs the necessary validation on all operations.

func (*ValidatingMeshStateStore) GetMeshState added in v0.12.0

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) GetRoute added in v0.11.0

func (v *ValidatingNetworkingStore) GetRoute(ctx context.Context, name string) (types.Route, error)

GetRoute returns a Route 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.

func (*ValidatingNetworkingStore) PutRoute added in v0.11.0

func (v *ValidatingNetworkingStore) PutRoute(ctx context.Context, route types.Route) error

PutRoute creates or updates a Route.

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

func (p *ValidatingPeerStore) Delete(ctx context.Context, id types.NodeID) error

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) ListIDs added in v0.11.0

func (p *ValidatingPeerStore) ListIDs(ctx context.Context) ([]types.NodeID, error)

ListIDs returns all node IDs 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

func (p *ValidatingPeerStore) PutEdge(ctx context.Context, edge types.MeshEdge) error

PutEdge validates the edge and then calls the underlying storage.Peers PutEdge method.

func (*ValidatingPeerStore) RemoveEdge added in v0.11.0

func (p *ValidatingPeerStore) RemoveEdge(ctx context.Context, from, to types.NodeID) error

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

Subscribe subscribe to node and edge changes from the underlying graph storage.

type ValidatingRBACStore added in v0.11.0

type ValidatingRBACStore struct {
	storage.RBAC
}

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) GetGroup added in v0.11.0

func (v *ValidatingRBACStore) GetGroup(ctx context.Context, name string) (types.Group, error)

GetGroup returns a group by name.

func (*ValidatingRBACStore) GetRole added in v0.11.0

func (v *ValidatingRBACStore) GetRole(ctx context.Context, name string) (types.Role, error)

GetRole returns a role 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) PutGroup added in v0.11.0

func (v *ValidatingRBACStore) PutGroup(ctx context.Context, group types.Group) error

PutGroup creates or updates a group.

func (*ValidatingRBACStore) PutRole added in v0.11.0

func (v *ValidatingRBACStore) PutRole(ctx context.Context, role types.Role) error

PutRole creates or updates a role.

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.

Jump to

Keyboard shortcuts

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