node

package
v0.0.0-...-b183826 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RStorage

type RStorage struct {
	RaftNode *raft.Raft
	Config   StorageConfig
	// contains filtered or unexported fields
}

RStorage represents key-value storage with raft based replication Also, it represents finite-state machine which processes Raft log events

func NewRStorage

func NewRStorage(config *StorageConfig) (*RStorage, error)

NewRStorage initiates a new RStorage node

func (*RStorage) AddVoter

func (s *RStorage) AddVoter(address string) error

AddVoter joins a new voter to a cluster must be called only on a leader

func (*RStorage) Apply

func (s *RStorage) Apply(logEntry *raft.Log) interface{}

Apply applies a Raft log entry to the key-value store.

func (*RStorage) DistributeConfig

func (s *RStorage) DistributeConfig() error

func (*RStorage) Get

func (s *RStorage) Get(key string) ([]byte, error)

Get retrieves the value associated with the given key from storage.

func (*RStorage) GetClusterServers

func (s *RStorage) GetClusterServers() ([]raft.Server, error)

GetClusterServers returns all cluster's servers

func (*RStorage) JoinCluster

func (s *RStorage) JoinCluster(leaderHTTPAddress string) error

JoinCluster sends a POST request to "join" address to ask the cluster leader join this node as a voter

func (*RStorage) Put

func (s *RStorage) Put(key string, value config.ServerConfig) error

func (*RStorage) RequestConfigFromLeader

func (s *RStorage) RequestConfigFromLeader() error

func (*RStorage) Restore

func (s *RStorage) Restore(serialized io.ReadCloser) error

Restore stores the key-value store to a previous state.

func (*RStorage) Set

func (s *RStorage) Set(key string, value []byte) error

Set stores the given value by key in the storage.

func (*RStorage) SetLocalConfig

func (s *RStorage) SetLocalConfig(encodedConfig []byte) error

func (*RStorage) Snapshot

func (s *RStorage) Snapshot() (raft.FSMSnapshot, error)

Snapshot returns FSMSnapshot which is used to save snapshot of the FSM

type StorageConfig

type StorageConfig struct {
	RaftBindAddress string
	HTTPBindAddress string
	NodeIdentifier  string
	JoinAddress     string
	DataDir         string
	Bootstrap       bool
}

Config struct handles configuration for a node

Jump to

Keyboard shortcuts

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