passthrough

package
v0.14.11 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package passthrough provides a passthrough storage provider. This is intended to be used by nodes that don't host their own storage, but need to query the storage of other nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consensus

type Consensus struct {
	*Provider
}

PassthroughConsensus is a consensus provider that returns an error for all write operations.

func (*Consensus) AddObserver

func (p *Consensus) AddObserver(context.Context, types.StoragePeer) error

AddObserver adds an observer to the consensus group.

func (*Consensus) AddVoter

AddVoter adds a voter to the consensus group.

func (*Consensus) DemoteVoter

func (p *Consensus) DemoteVoter(context.Context, types.StoragePeer) error

DemoteVoter demotes a voter to an observer.

func (*Consensus) GetLeader

func (p *Consensus) GetLeader(context.Context) (types.StoragePeer, error)

GetLeader returns the leader of the storage group.

func (*Consensus) GetPeer added in v0.11.5

func (p *Consensus) GetPeer(ctx context.Context, peerID string) (types.StoragePeer, error)

GetPeer returns the peer with the given ID.

func (*Consensus) GetPeers added in v0.7.2

func (p *Consensus) GetPeers(context.Context) ([]types.StoragePeer, error)

GetPeers returns the peers of the storage group.

func (*Consensus) IsLeader

func (p *Consensus) IsLeader() bool

IsLeader returns true if the node is the leader of the storage group.

func (*Consensus) IsMember

func (p *Consensus) IsMember() bool

IsMember returns true if the node is a member of the storage group.

func (*Consensus) RemovePeer

func (p *Consensus) RemovePeer(ctx context.Context, peer types.StoragePeer, wait bool) error

RemovePeer removes a peer from the consensus group. If wait is true, the function will wait for the peer to be removed.

func (*Consensus) StepDown added in v0.12.3

func (p *Consensus) StepDown(context.Context) error

StepDown is a no-op.

type GraphStore added in v0.12.0

type GraphStore struct {
	*MeshDataStore
}

GraphStore is a passthrough graph store that uses the storage API to field read requests.

func (*GraphStore) AddEdge added in v0.12.0

func (g *GraphStore) AddEdge(sourceNode, targetNode types.NodeID, edge graph.Edge[types.NodeID]) error

func (*GraphStore) AddVertex added in v0.12.0

func (g *GraphStore) AddVertex(nodeID types.NodeID, node types.MeshNode, props graph.VertexProperties) error

func (*GraphStore) Edge added in v0.12.0

func (g *GraphStore) Edge(sourceNode, targetNode types.NodeID) (edge graph.Edge[types.NodeID], err error)

func (*GraphStore) ListEdges added in v0.12.0

func (g *GraphStore) ListEdges() ([]graph.Edge[types.NodeID], error)

func (*GraphStore) ListVertices added in v0.12.0

func (g *GraphStore) ListVertices() ([]types.NodeID, error)

func (*GraphStore) RemoveEdge added in v0.12.0

func (g *GraphStore) RemoveEdge(sourceNode, targetNode types.NodeID) error

func (*GraphStore) RemoveVertex added in v0.12.0

func (g *GraphStore) RemoveVertex(nodeID types.NodeID) error

func (*GraphStore) Subscribe added in v0.12.0

func (*GraphStore) UpdateEdge added in v0.12.0

func (g *GraphStore) UpdateEdge(sourceNode, targetNode types.NodeID, edge graph.Edge[types.NodeID]) error

func (*GraphStore) Vertex added in v0.12.0

func (g *GraphStore) Vertex(nodeID types.NodeID) (node types.MeshNode, props graph.VertexProperties, err error)

func (*GraphStore) VertexCount added in v0.12.0

func (g *GraphStore) VertexCount() (int, error)

type MeshDataStore added in v0.12.0

type MeshDataStore struct {
	// contains filtered or unexported fields
}

MeshDataStore is a passthrough data store that uses the storage API to field read requests.

func NewMeshDataStore added in v0.12.0

func NewMeshDataStore(dialer transport.NodeDialer) *MeshDataStore

NewMeshDataStore creates a new passthrough data store.

func (*MeshDataStore) GraphStore added in v0.12.0

func (mdb *MeshDataStore) GraphStore() storage.GraphStore

GraphStore returns the interface for managing network topology and data about peers.

func (*MeshDataStore) MeshState added in v0.12.0

func (mdb *MeshDataStore) MeshState() storage.MeshState

MeshState returns the interface for querying mesh state.

func (*MeshDataStore) Networking added in v0.12.0

func (mdb *MeshDataStore) Networking() storage.Networking

Networking returns the interface for managing networking in the mesh.

func (*MeshDataStore) RBAC added in v0.12.0

func (mdb *MeshDataStore) RBAC() storage.RBAC

RBAC returns the interface for managing RBAC policies in the mesh.

type NetworkingStore added in v0.12.0

type NetworkingStore struct {
	*MeshDataStore
}

NetworkingStore is a passthrough networking store that uses the storage API to field read requests.

func (*NetworkingStore) DeleteNetworkACL added in v0.12.0

func (nw *NetworkingStore) DeleteNetworkACL(ctx context.Context, name string) error

func (*NetworkingStore) DeleteRoute added in v0.12.0

func (nw *NetworkingStore) DeleteRoute(ctx context.Context, name string) error

func (*NetworkingStore) GetNetworkACL added in v0.12.0

func (nw *NetworkingStore) GetNetworkACL(ctx context.Context, name string) (types.NetworkACL, error)

func (*NetworkingStore) GetRoute added in v0.12.0

func (nw *NetworkingStore) GetRoute(ctx context.Context, name string) (types.Route, error)

func (*NetworkingStore) GetRoutesByCIDR added in v0.12.0

func (nw *NetworkingStore) GetRoutesByCIDR(ctx context.Context, cidr netip.Prefix) (types.Routes, error)

func (*NetworkingStore) GetRoutesByNode added in v0.12.0

func (nw *NetworkingStore) GetRoutesByNode(ctx context.Context, nodeID types.NodeID) (types.Routes, error)

func (*NetworkingStore) ListNetworkACLs added in v0.12.0

func (nw *NetworkingStore) ListNetworkACLs(ctx context.Context) (types.NetworkACLs, error)

func (*NetworkingStore) ListRoutes added in v0.12.0

func (nw *NetworkingStore) ListRoutes(ctx context.Context) (types.Routes, error)

func (*NetworkingStore) PutNetworkACL added in v0.12.0

func (nw *NetworkingStore) PutNetworkACL(ctx context.Context, acl types.NetworkACL) error

func (*NetworkingStore) PutRoute added in v0.12.0

func (nw *NetworkingStore) PutRoute(ctx context.Context, route types.Route) error

type Options

type Options struct {
	// NodeID is the ID of the node.
	NodeID string
	// Dialer is the dialer to use for connecting to other nodes.
	Dialer transport.NodeDialer
	// LogLevel is the log level to use.
	LogLevel string
	// LogFormat is the log format to use.
	LogFormat string
}

Options are the passthrough options.

type Provider

type Provider struct {
	Options
	// contains filtered or unexported fields
}

Provider is a storage provider that passes through all storage operations to another node in the cluster.

func NewProvider

func NewProvider(opts Options) *Provider

NewProvider returns a new passthrough storage provider.

func (*Provider) Bootstrap

func (p *Provider) Bootstrap(ctx context.Context) error

func (*Provider) Close

func (p *Provider) Close() error

func (*Provider) Consensus

func (p *Provider) Consensus() storage.Consensus

func (*Provider) ListenPort

func (p *Provider) ListenPort() uint16

func (*Provider) MeshDB added in v0.9.0

func (p *Provider) MeshDB() storage.MeshDB

func (*Provider) MeshStorage

func (p *Provider) MeshStorage() storage.MeshStorage

func (*Provider) Start

func (p *Provider) Start(ctx context.Context) error

func (*Provider) Status

func (p *Provider) Status() *v1.StorageStatus

type RBACStore added in v0.12.0

type RBACStore struct {
	*MeshDataStore
}

RBACStore is a passthrough RBAC store that uses the storage API to field read requests.

func (*RBACStore) DeleteGroup added in v0.12.0

func (r *RBACStore) DeleteGroup(ctx context.Context, name string) error

func (*RBACStore) DeleteRole added in v0.12.0

func (r *RBACStore) DeleteRole(ctx context.Context, name string) error

func (*RBACStore) DeleteRoleBinding added in v0.12.0

func (r *RBACStore) DeleteRoleBinding(ctx context.Context, name string) error

func (*RBACStore) GetEnabled added in v0.12.0

func (r *RBACStore) GetEnabled(ctx context.Context) (bool, error)

func (*RBACStore) GetGroup added in v0.12.0

func (r *RBACStore) GetGroup(ctx context.Context, name string) (types.Group, error)

func (*RBACStore) GetRole added in v0.12.0

func (r *RBACStore) GetRole(ctx context.Context, name string) (types.Role, error)

func (*RBACStore) GetRoleBinding added in v0.12.0

func (r *RBACStore) GetRoleBinding(ctx context.Context, name string) (types.RoleBinding, error)

func (*RBACStore) ListGroups added in v0.12.0

func (r *RBACStore) ListGroups(ctx context.Context) ([]types.Group, error)

func (*RBACStore) ListNodeRoles added in v0.12.0

func (r *RBACStore) ListNodeRoles(ctx context.Context, nodeID types.NodeID) (types.RolesList, error)

func (*RBACStore) ListRoleBindings added in v0.12.0

func (r *RBACStore) ListRoleBindings(ctx context.Context) ([]types.RoleBinding, error)

func (*RBACStore) ListRoles added in v0.12.0

func (r *RBACStore) ListRoles(ctx context.Context) (types.RolesList, error)

func (*RBACStore) ListUserRoles added in v0.12.0

func (r *RBACStore) ListUserRoles(ctx context.Context, user types.NodeID) (types.RolesList, error)

func (*RBACStore) PutGroup added in v0.12.0

func (r *RBACStore) PutGroup(ctx context.Context, group types.Group) error

func (*RBACStore) PutRole added in v0.12.0

func (r *RBACStore) PutRole(ctx context.Context, role types.Role) error

func (*RBACStore) PutRoleBinding added in v0.12.0

func (r *RBACStore) PutRoleBinding(ctx context.Context, rolebinding types.RoleBinding) error

func (*RBACStore) SetEnabled added in v0.12.0

func (r *RBACStore) SetEnabled(ctx context.Context, enabled bool) error

type StateStore added in v0.12.0

type StateStore struct {
	*MeshDataStore
}

StateStore is a passthrough state store that uses the storage API to field read requests.

func (*StateStore) GetMeshState added in v0.12.0

func (st *StateStore) GetMeshState(ctx context.Context) (types.NetworkState, error)

func (*StateStore) SetMeshState added in v0.13.12

func (st *StateStore) SetMeshState(_ context.Context, _ types.NetworkState) error

type Storage

type Storage struct {
	*Provider
}

func (*Storage) Close

func (p *Storage) Close() error

Close closes the storage.

func (*Storage) Delete

func (p *Storage) Delete(ctx context.Context, key []byte) error

Delete removes a key.

func (*Storage) GetValue

func (p *Storage) GetValue(ctx context.Context, key []byte) ([]byte, error)

GetValue returns the value of a key.

func (*Storage) IterPrefix

func (p *Storage) IterPrefix(ctx context.Context, prefix []byte, fn storage.PrefixIterator) 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.

func (*Storage) ListKeys added in v0.8.0

func (p *Storage) ListKeys(ctx context.Context, prefix []byte) ([][]byte, error)

ListKeys returns all keys with a given prefix.

func (*Storage) PutValue

func (p *Storage) PutValue(ctx context.Context, key, value []byte, ttl time.Duration) error

PutValue sets the value of a key. TTL is optional and can be set to 0.

func (*Storage) Subscribe

func (p *Storage) Subscribe(ctx context.Context, prefix []byte, fn storage.KVSubscribeFunc) (context.CancelFunc, error)

Subscribe will call the given function whenever a key with the given prefix is changed. The returned function can be called to unsubscribe.

Jump to

Keyboard shortcuts

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