external

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: 21 Imported by: 0

Documentation

Overview

Package external provides a storage provider that uses a storage plugin to manage mesh storage and consensus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consensus

type Consensus struct {
	*Provider
}

Consensus is a consensus implementation that uses a storage plugin.

func (*Consensus) AddObserver

func (ext *Consensus) AddObserver(ctx context.Context, peer types.StoragePeer) error

AddObserver adds an observer to the consensus group.

func (*Consensus) AddVoter

func (ext *Consensus) AddVoter(ctx context.Context, peer types.StoragePeer) error

AddVoter adds a voter to the consensus group.

func (*Consensus) DemoteVoter

func (ext *Consensus) DemoteVoter(ctx context.Context, peer types.StoragePeer) error

DemoteVoter demotes a voter to an observer.

func (*Consensus) GetLeader

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

GetLeader returns the leader of the storage group.

func (*Consensus) GetPeer added in v0.11.5

func (ext *Consensus) GetPeer(ctx context.Context, id string) (types.StoragePeer, error)

GetPeer returns the peer with the given ID.

func (*Consensus) GetPeers added in v0.7.2

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

GetPeers returns the peers of the storage group.

func (*Consensus) IsLeader

func (ext *Consensus) IsLeader() bool

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

func (*Consensus) IsMember

func (ext *Consensus) IsMember() bool

IsMember returns true if the node is a member of the storage group. External storage providers should always be members.

func (*Consensus) RemovePeer

func (ext *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 (ext *Consensus) StepDown(ctx context.Context) error

StepDown should be called to relinquish leadership of the storage group.

type ExternalStorage

type ExternalStorage struct {
	*Provider
}

ExternalStorage is a storage implementation that uses a storage plugin.

func (*ExternalStorage) Delete

func (ext *ExternalStorage) Delete(ctx context.Context, key []byte) error

Delete removes a key.

func (*ExternalStorage) GetValue

func (ext *ExternalStorage) GetValue(ctx context.Context, key []byte) ([]byte, error)

GetValue returns the value of a key.

func (*ExternalStorage) IterPrefix

func (ext *ExternalStorage) 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. The iteration will stop if the iterator returns an error.

func (*ExternalStorage) ListKeys added in v0.8.0

func (ext *ExternalStorage) ListKeys(ctx context.Context, prefix []byte) ([][]byte, error)

ListKeys returns all keys with a given prefix.

func (*ExternalStorage) PutValue

func (ext *ExternalStorage) 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 (*ExternalStorage) Subscribe

func (ext *ExternalStorage) 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.

type Options

type Options struct {
	// NodeID is the ID of the node.
	NodeID types.NodeID
	// Config is the configuration for the storage provider plugin.
	Config *v1.PluginConfiguration
	// Server is the address of a server for the storage provider.
	Server string
	// TLSConfig is the TLS configuration for the storage provider.
	TLSConfig *tls.Config
	// LogLevel is the log level for the storage provider.
	LogLevel string
	// LogFormat is the log format for the storage provider.
	LogFormat string
}

Options are the options for the external storage provider.

type Provider

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

Provider is a storage provider that uses a storage plugin.

func NewProvider

func NewProvider(opts Options) *Provider

NewProvider returns a new ExternalStorageProvider.

func (*Provider) Bootstrap

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

Bootstrap should bootstrap the provider for first-time usage.

func (*Provider) Close

func (ext *Provider) Close() error

Close should close the underlying storage as well as any other resources that the provider may have allocated.

func (*Provider) Consensus

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

Consensus returns the underlying Consensus instance.

func (*Provider) ListenPort

func (ext *Provider) ListenPort() uint16

ListenPort attempts to return the TCP port that the storage provider is listening on.

func (*Provider) MeshDB added in v0.9.0

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

MeshDB returns the underlying MeshDB instance.

func (*Provider) MeshStorage

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

MeshStorage returns the underlying MeshStorage instance.

func (*Provider) Start

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

Start should start the provider and any resources that it may need.

func (*Provider) Status

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

Status returns the status of the storage provider.

Jump to

Keyboard shortcuts

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