Documentation ¶
Overview ¶
Package storage defines the interfaces for the storage provider.
Index ¶
- Variables
- func ExpandACL(ctx context.Context, rbac RBAC, acl types.NetworkACL) error
- func ExpandACLs(ctx context.Context, rbac RBAC, acls types.NetworkACLs) error
- func IsSystemGroup(name string) bool
- func IsSystemRole(name string) bool
- func IsSystemRoleBinding(name string) bool
- type Consensus
- type ConsensusStorage
- type DualStorage
- type KVSubscribeFunc
- type MeshDB
- type MeshState
- type MeshStorage
- type Networking
- type PeerFilter
- type PeerFilters
- type PeerSubscribeFunc
- type Peers
- type PrefixIterator
- type Provider
- type RBAC
Constants ¶
This section is empty.
Variables ¶
var ( // BootstrapNodesNetworkACLName is the name of the bootstrap nodes NetworkACL. BootstrapNodesNetworkACLName = []byte("bootstrap-nodes") // NetworkACLsPrefix is where NetworkACLs are stored in the database. NetworkACLsPrefix = types.RegistryPrefix.For([]byte("network-acls")) // RoutesPrefix is where Routes are stored in the database. RoutesPrefix = types.RegistryPrefix.For([]byte("routes")) )
var ( // MeshAdminRole is the name of the mesh admin role. MeshAdminRole = []byte("mesh-admin") // MeshAdminRoleBinding is the name of the mesh admin rolebinding. MeshAdminRoleBinding = []byte("mesh-admin") // VotersRole is the name of the voters role. VotersRole = []byte("voters") // VotersGroup is the name of the voters group. VotersGroup = []byte("voters") // BootstrapVotersRoleBinding is the name of the bootstrap voters rolebinding. BootstrapVotersRoleBinding = []byte("bootstrap-voters") )
var EdgesPrefix = types.RegistryPrefix.ForString("edges")
EdgesPrefix is where edges are stored in the database. edges are indexed by their source and target node IDs in the format /registry/edges/<source>/<target>.
var NodesPrefix = types.RegistryPrefix.ForString("nodes")
NodesPrefix is where nodes are stored in the database. nodes are indexed by their ID in the format /registry/nodes/<id>.
Functions ¶
func ExpandACL ¶ added in v0.9.0
ExpandACL will use the given RBAC interface to expand any group references in the ACL.
func ExpandACLs ¶ added in v0.9.0
ExpandACLs will use the given RBAC interface to expand any group references in the ACLs.
func IsSystemGroup ¶ added in v0.9.0
IsSystemGroup returns true if the group is a system group.
func IsSystemRole ¶ added in v0.9.0
IsSystemRole returns true if the role is a system role.
func IsSystemRoleBinding ¶ added in v0.9.0
IsSystemRoleBinding returns true if the rolebinding is a system rolebinding.
Types ¶
type Consensus ¶ added in v0.7.0
type Consensus interface { // IsLeader returns true if the node is the leader of the storage group. IsLeader() bool // IsMember returns true if the node is a member of the storage group. IsMember() bool // GetPeers returns the peers of the storage group. GetPeers(context.Context) ([]*v1.StoragePeer, error) // GetLeader returns the leader of the storage group. GetLeader(context.Context) (*v1.StoragePeer, error) // AddVoter adds a voter to the consensus group. AddVoter(context.Context, *v1.StoragePeer) error // AddObserver adds an observer to the consensus group. AddObserver(context.Context, *v1.StoragePeer) error // DemoteVoter demotes a voter to an observer. DemoteVoter(context.Context, *v1.StoragePeer) error // RemovePeer removes a peer from the consensus group. If wait // is true, the function will wait for the peer to be removed. RemovePeer(ctx context.Context, peer *v1.StoragePeer, wait bool) error }
Consensus is the interface for configuring storage consensus.
type ConsensusStorage ¶ added in v0.7.2
type ConsensusStorage interface { io.Closer raft.LogStore raft.StableStore // Snapshot returns a snapshot of the storage. Snapshot(ctx context.Context) (io.Reader, error) // Restore restores a snapshot of the storage. Restore(ctx context.Context, r io.Reader) error }
ConsensusStorage is the interface for storing and retrieving data about the state of consensus. This is currently only used by the built-in raftstorage implementation.
type DualStorage ¶ added in v0.3.0
type DualStorage interface { MeshStorage ConsensusStorage }
DualStorage represents a storage interface that can serve as both mesh and consensus storage.
type KVSubscribeFunc ¶ added in v0.9.0
type KVSubscribeFunc func(key, value []byte)
KVSubscribeFunc is the function signature for subscribing to changes to a key.
type MeshDB ¶ added in v0.9.0
type MeshDB interface { // Peers returns the interface for managing nodes in the mesh. Peers() Peers // PeerGraph returns the interface for querying the peer graph. PeerGraph() types.PeerGraph // RBAC returns the interface for managing RBAC policies in the mesh. RBAC() RBAC // MeshState returns the interface for querying mesh state. MeshState() MeshState // Networking returns the interface for managing networking in the mesh. Networking() Networking }
MeshDB is the interface for the mesh database. It provides access to all storage interfaces.
type MeshState ¶ added in v0.9.0
type MeshState interface { // GetIPv6Prefix returns the IPv6 prefix. GetIPv6Prefix(ctx context.Context) (netip.Prefix, error) // SetIPv6Prefix sets the IPv6 prefix. SetIPv6Prefix(ctx context.Context, prefix netip.Prefix) error // GetIPv4Prefix returns the IPv4 prefix. GetIPv4Prefix(ctx context.Context) (netip.Prefix, error) // SetIPv4Prefix sets the IPv4 prefix. SetIPv4Prefix(ctx context.Context, prefix netip.Prefix) error // GetMeshDomain returns the mesh domain. GetMeshDomain(ctx context.Context) (string, error) // SetMeshDomain sets the mesh domain. SetMeshDomain(ctx context.Context, domain string) error }
MeshState is the interface for querying mesh state.
type MeshStorage ¶ added in v0.3.0
type MeshStorage interface { // Close should close the underlying storage as well as any other resources // that the provider may have allocated. This should be called automatically // by the provider. io.Closer // GetValue returns the value of a key. GetValue(ctx context.Context, key []byte) ([]byte, error) // PutValue sets the value of a key. TTL is optional and can be set to 0. PutValue(ctx context.Context, key, value []byte, ttl time.Duration) error // Delete removes a key. Delete(ctx context.Context, key []byte) error // ListKeys returns all keys with a given prefix. ListKeys(ctx context.Context, prefix []byte) ([][]byte, error) // IterPrefix iterates over all keys with a given prefix. It is important // that the iterator not attempt any write operations as this will cause // a deadlock. The iteration will stop if the iterator returns an error. IterPrefix(ctx context.Context, prefix []byte, fn PrefixIterator) error // Subscribe will call the given function whenever a key with the given prefix is changed. // The returned function can be called to unsubscribe. Subscribe(ctx context.Context, prefix []byte, fn KVSubscribeFunc) (context.CancelFunc, error) }
MeshStorage is the interface for storing and retrieving data about the state of the mesh.
type Networking ¶ added in v0.9.0
type Networking interface { // PutNetworkACL creates or updates a NetworkACL. PutNetworkACL(ctx context.Context, acl types.NetworkACL) error // GetNetworkACL returns a NetworkACL by name. GetNetworkACL(ctx context.Context, name string) (types.NetworkACL, error) // DeleteNetworkACL deletes a NetworkACL by name. DeleteNetworkACL(ctx context.Context, name string) error // ListNetworkACLs returns a list of NetworkACLs. ListNetworkACLs(ctx context.Context) (types.NetworkACLs, error) // PutRoute creates or updates a Route. PutRoute(ctx context.Context, route types.Route) error // GetRoute returns a Route by name. GetRoute(ctx context.Context, name string) (types.Route, error) // GetRoutesByNode returns a list of Routes for a given Node. GetRoutesByNode(ctx context.Context, nodeID types.NodeID) (types.Routes, error) // GetRoutesByCIDR returns a list of Routes for a given CIDR. GetRoutesByCIDR(ctx context.Context, cidr netip.Prefix) (types.Routes, error) // DeleteRoute deletes a Route by name. DeleteRoute(ctx context.Context, name string) error // ListRoutes returns a list of Routes. ListRoutes(ctx context.Context) (types.Routes, error) }
Networking is the interface to the database models for network resources.
type PeerFilter ¶ added in v0.9.0
PeerFilter is a filter for nodes.
func FeatureFilter ¶ added in v0.9.0
func FeatureFilter(feature v1.Feature) PeerFilter
FeatureFilter returns a new filter that matches nodes with a given feature.
func IsPublicFilter ¶ added in v0.9.0
func IsPublicFilter() PeerFilter
IsPublicFilter returns a new filter that matches public nodes.
func ZoneIDFilter ¶ added in v0.9.0
func ZoneIDFilter(zoneID string) PeerFilter
ZoneIDFilter returns a new filter that matches nodes in a given zone.
type PeerFilters ¶ added in v0.9.0
type PeerFilters []PeerFilter
PeerFilters is a list of filters.
type PeerSubscribeFunc ¶ added in v0.9.0
PeerSubscribeFunc is a function that can be used to subscribe to peer changes. The function is called with multiple peers when the change reflects a new edge being added or removed. The function is called with a single peer when the change reflects a node being added or removed.
type Peers ¶ added in v0.9.0
type Peers interface { // Put creates or updates a node. Put(ctx context.Context, n types.MeshNode) error // Get gets a node by ID. Get(ctx context.Context, id types.NodeID) (types.MeshNode, error) // GetByPubKey gets a node by their public key. GetByPubKey(ctx context.Context, key crypto.PublicKey) (types.MeshNode, error) // Delete deletes a node. Delete(ctx context.Context, id types.NodeID) error // List lists all nodes. List(ctx context.Context, filters ...PeerFilter) ([]types.MeshNode, error) // ListIDs lists all node IDs. ListIDs(ctx context.Context) ([]types.NodeID, error) // Subscribe subscribes to node changes. Subscribe(ctx context.Context, fn PeerSubscribeFunc) (context.CancelFunc, error) // AddEdge adds an edge between two nodes. PutEdge(ctx context.Context, edge types.MeshEdge) error // GetEdge gets an edge between two nodes. GetEdge(ctx context.Context, from, to types.NodeID) (types.MeshEdge, error) // RemoveEdge removes an edge between two nodes. RemoveEdge(ctx context.Context, from, to types.NodeID) error }
Peers is the peers interface.
type PrefixIterator ¶
PrefixIterator is the function signature for iterating over all keys with a given prefix.
type Provider ¶ added in v0.7.0
type Provider interface { // Close should close the underlying storage as well as any other resources // that the provider may have allocated. io.Closer // Start should start the provider and any resources that it may need. Start(context.Context) error // Bootstrap should bootstrap the provider for first-time usage. Bootstrap(context.Context) error // Status returns the status of the storage provider. It should never error. // If inaccurate status is available, the node should return itself as a peer // with a message describing the inaccuracy. Status() *v1.StorageStatus // ListenPort should return the TCP port that the storage provider is listening on. ListenPort() uint16 // MeshDB returns the underlying MeshDB instance. The provider does not // need to guarantee consistency on read operations. MeshDB() MeshDB // Consensus returns the underlying Consensus instance for managing voting/observing // nodes and leader election. Consensus() Consensus // MeshStorage returns the underlying raw MeshStorage instance. The provider does // not need to guarantee consistency on read operations. This should only be used // for arbitrary key/value storage that has not been abstracted behind the MeshDB. MeshStorage() MeshStorage }
Provider is a provider of MeshStorage.
type RBAC ¶ added in v0.9.0
type RBAC interface { // SetEnabled sets the RBAC enabled state. SetEnabled(ctx context.Context, enabled bool) error // GetEnabled returns the RBAC enabled state. GetEnabled(ctx context.Context) (bool, error) // PutRole creates or updates a role. PutRole(ctx context.Context, role types.Role) error // GetRole returns a role by name. GetRole(ctx context.Context, name string) (types.Role, error) // DeleteRole deletes a role by name. DeleteRole(ctx context.Context, name string) error // ListRoles returns a list of all roles. ListRoles(ctx context.Context) (types.RolesList, error) // PutRoleBinding creates or updates a rolebinding. PutRoleBinding(ctx context.Context, rolebinding types.RoleBinding) error // GetRoleBinding returns a rolebinding by name. GetRoleBinding(ctx context.Context, name string) (types.RoleBinding, error) // DeleteRoleBinding deletes a rolebinding by name. DeleteRoleBinding(ctx context.Context, name string) error // ListRoleBindings returns a list of all rolebindings. ListRoleBindings(ctx context.Context) ([]types.RoleBinding, error) // PutGroup creates or updates a group. PutGroup(ctx context.Context, group types.Group) error // GetGroup returns a group by name. GetGroup(ctx context.Context, name string) (types.Group, error) // DeleteGroup deletes a group by name. DeleteGroup(ctx context.Context, name string) error // ListGroups returns a list of all groups. ListGroups(ctx context.Context) ([]types.Group, error) // ListNodeRoles returns a list of all roles for a node. ListNodeRoles(ctx context.Context, nodeID types.NodeID) (types.RolesList, error) // ListUserRoles returns a list of all roles for a user. ListUserRoles(ctx context.Context, user types.NodeID) (types.RolesList, error) }
RBAC is the interface to the database models for RBAC.
Directories ¶
Path | Synopsis |
---|---|
Package errors contains error definitions for storage providers.
|
Package errors contains error definitions for storage providers. |
Package meshdb implements a storage.Database using any storage.MeshStorage instance.
|
Package meshdb implements a storage.Database using any storage.MeshStorage instance. |
graphstore
Package graph implements a graph data structure for the mesh network.
|
Package graph implements a graph data structure for the mesh network. |
networking
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. |
peers
Package peers contains an interface for managing nodes in the mesh.
|
Package peers contains an interface for managing nodes in the mesh. |
rbac
Package rbac contains interfaces to the database models for RBAC.
|
Package rbac contains interfaces to the database models for RBAC. |
state
Package state provides an interface for querying mesh state.
|
Package state provides an interface for querying mesh state. |
providers
|
|
backends/badgerdb
Package badgerdb implements the storage backends using BadgerDB.
|
Package badgerdb implements the storage backends using BadgerDB. |
external
Package external provides a storage provider that uses a storage plugin to manage mesh storage and consensus.
|
Package external provides a storage provider that uses a storage plugin to manage mesh storage and consensus. |
passthrough
Package passthrough provides a passthrough storage provider.
|
Package passthrough provides a passthrough storage provider. |
raftstorage
Package raftstorage implements a Raft-backed storage provider.
|
Package raftstorage implements a Raft-backed storage provider. |
raftstorage/fsm
Package fsm implements the Raft FSM.
|
Package fsm implements the Raft FSM. |
raftstorage/raftlogs
Package raftlogs provides facilities for applying raft logs to a database.
|
Package raftlogs provides facilities for applying raft logs to a database. |
raftstorage/snapshots
Package snapshots provides an interface for managing raft snapshots.
|
Package snapshots provides an interface for managing raft snapshots. |
Package storageutil contains utility functions for mesh database interactions.
|
Package storageutil contains utility functions for mesh database interactions. |
Package testutil contains testing utilities for storage providers and backends.
|
Package testutil contains testing utilities for storage providers and backends. |