passthrough

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: Apache-2.0 Imports: 12 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, *v1.StoragePeer) error

AddObserver adds an observer to the consensus group.

func (*Consensus) AddVoter

func (p *Consensus) AddVoter(context.Context, *v1.StoragePeer) error

AddVoter adds a voter to the consensus group.

func (*Consensus) DemoteVoter

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

DemoteVoter demotes a voter to an observer.

func (*Consensus) GetLeader

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

GetLeader returns the leader 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 *v1.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.

type Options

type Options struct {
	// Dialer is the dialer to use for connecting to other nodes.
	Dialer transport.NodeDialer
	// LogLevel is the log level to use.
	LogLevel 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) 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 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 string) error

Delete removes a key.

func (*Storage) GetValue

func (p *Storage) GetValue(ctx context.Context, key string) (string, error)

GetValue returns the value of a key.

func (*Storage) IterPrefix

func (p *Storage) IterPrefix(ctx context.Context, prefix string, 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) List

func (p *Storage) List(ctx context.Context, prefix string) ([]string, error)

List returns all keys with a given prefix.

func (*Storage) PutValue

func (p *Storage) PutValue(ctx context.Context, key, value string, 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 string, 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.

Jump to

Keyboard shortcuts

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