Documentation ¶
Overview ¶
Package external provides a storage provider that uses a storage plugin to manage mesh storage and consensus.
Index ¶
- type Consensus
- func (ext *Consensus) AddObserver(ctx context.Context, peer *v1.StoragePeer) error
- func (ext *Consensus) AddVoter(ctx context.Context, peer *v1.StoragePeer) error
- func (ext *Consensus) DemoteVoter(ctx context.Context, peer *v1.StoragePeer) error
- func (ext *Consensus) GetLeader(ctx context.Context) (*v1.StoragePeer, error)
- func (ext *Consensus) GetPeers(ctx context.Context) ([]*v1.StoragePeer, error)
- func (ext *Consensus) IsLeader() bool
- func (ext *Consensus) IsMember() bool
- func (ext *Consensus) RemovePeer(ctx context.Context, peer *v1.StoragePeer, wait bool) error
- type ExternalStorage
- func (ext *ExternalStorage) Delete(ctx context.Context, key []byte) error
- func (ext *ExternalStorage) GetValue(ctx context.Context, key []byte) ([]byte, error)
- func (ext *ExternalStorage) IterPrefix(ctx context.Context, prefix []byte, fn storage.PrefixIterator) error
- func (ext *ExternalStorage) ListKeys(ctx context.Context, prefix []byte) ([][]byte, error)
- func (ext *ExternalStorage) PutValue(ctx context.Context, key, value []byte, ttl time.Duration) error
- func (ext *ExternalStorage) Subscribe(ctx context.Context, prefix []byte, fn storage.SubscribeFunc) (context.CancelFunc, error)
- type Options
- type Provider
- func (ext *Provider) Bootstrap(ctx context.Context) error
- func (ext *Provider) Close() error
- func (ext *Provider) Consensus() storage.Consensus
- func (ext *Provider) ListenPort() uint16
- func (ext *Provider) MeshStorage() storage.MeshStorage
- func (ext *Provider) Start(ctx context.Context) error
- func (ext *Provider) Status() *v1.StorageStatus
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 ¶
AddObserver adds an observer to the consensus group.
func (*Consensus) DemoteVoter ¶
DemoteVoter demotes a voter to an observer.
func (*Consensus) IsMember ¶
IsMember returns true if the node is a member of the storage group. External storage providers should always be members.
func (*Consensus) RemovePeer ¶
RemovePeer removes a peer from the consensus group. If wait is true, the function will wait for the peer to be removed.
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) 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) 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.SubscribeFunc) (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 string // 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 }
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 ¶
NewProvider returns a new ExternalStorageProvider.
func (*Provider) Close ¶
Close should close the underlying storage as well as any other resources that the provider may have allocated.
func (*Provider) ListenPort ¶
ListenPort attempts to return the TCP port that the storage provider is listening on.
func (*Provider) MeshStorage ¶
func (ext *Provider) MeshStorage() storage.MeshStorage
MeshStorage returns the underlying MeshStorage instance. The provider does not need to guarantee consistency on read operations.
func (*Provider) Status ¶
func (ext *Provider) Status() *v1.StorageStatus
Status returns the status of the storage provider.