red

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: GPL-3.0 Imports: 27 Imported by: 0

README

RedQueen

Go Report Card CodeQL build-docker build-release codecov Godoc Releases LICENSE

简体中文

Inspired by the supercomputer (Red Queen) in "Resident Evil", the distributed key-value store is close to it in the distributed system

This is a reliable distributed key-value store based on the raft algorithm, and internal provides advanced functions such as distributed-lock...

Client call

# go get github.com/RealFax/RedQueen@latest

Code example

About Internal Advanced Functions

internal advanced functions require long-term experiments to ensure its reliability

🧪 Distributed-lock (experimental functions)

RedQueen internal implements a mutex and provides grpc interface calls

🔍 Third-party

Documentation

Index

Constants

View Source
const (
	StoreSuffix = "data"
)

Variables

This section is empty.

Functions

func NewLockerBackend

func NewLockerBackend(
	ns store.Namespace,
	raftApplyFunc func(context.Context, *serverpb.RaftLogPayload, time.Duration) (raft.ApplyFuture, error),
) locker.Backend

Types

type FSM

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

func NewFSM

func NewFSM(s store.Store) *FSM

func (*FSM) Apply

func (f *FSM) Apply(log *raft.Log) any

func (*FSM) Restore

func (f *FSM) Restore(rc io.ReadCloser) error

func (*FSM) Snapshot

func (f *FSM) Snapshot() (raft.FSMSnapshot, error)

type FSMHandleFunc

type FSMHandleFunc func(*serverpb.RaftLogPayload) error

type LockerBackendWrapper

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

func (LockerBackendWrapper) Del

func (w LockerBackendWrapper) Del(key []byte) error

func (LockerBackendWrapper) Get

func (w LockerBackendWrapper) Get(key []byte) (*store.Value, error)

func (LockerBackendWrapper) TrySetWithTTL

func (w LockerBackendWrapper) TrySetWithTTL(key, value []byte, ttl uint32) error

func (LockerBackendWrapper) Watch

type Raft

type Raft struct {
	*raft.Raft
	// contains filtered or unexported fields
}

func NewRaft

func NewRaft(cfg RaftConfig) (*Raft, error)

func NewRaftWithOptions

func NewRaftWithOptions(opts ...RaftServerOption) (*Raft, error)

func (*Raft) AddCluster

func (r *Raft) AddCluster(id raft.ServerID, addr raft.ServerAddress) error

type RaftConfig

type RaftConfig struct {
	Bootstrap               bool
	MaxSnapshots            int
	ServerID, Addr, DataDir string
	Store                   store.Store
	Clusters                []raft.Server
}

type RaftServerOption

type RaftServerOption func(*Raft) error

func RaftWithBoltLogStore

func RaftWithBoltLogStore(path string) RaftServerOption

func RaftWithBootstrap

func RaftWithBootstrap() RaftServerOption

func RaftWithClusters

func RaftWithClusters(clusters []raft.Server) RaftServerOption

func RaftWithConfig

func RaftWithConfig(cfg *raft.Config) RaftServerOption

func RaftWithEmpty

func RaftWithEmpty() RaftServerOption

func RaftWithFileSnapshotStore

func RaftWithFileSnapshotStore(path string, retain int, logOut io.Writer) RaftServerOption

func RaftWithStdFSM

func RaftWithStdFSM(store store.Store) RaftServerOption

func RaftWithStdStableStore

func RaftWithStdStableStore(store store.Store) RaftServerOption

func RaftWithTCPTransport

func RaftWithTCPTransport(addr string, maxPool int, timeout time.Duration, logOut io.Writer) RaftServerOption

type Server

type Server struct {
	serverpb.UnimplementedKVServer
	serverpb.UnimplementedLockerServer
	serverpb.UnimplementedRedQueenServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg *config.Config) (*Server, error)

func (*Server) Close

func (s *Server) Close() (err error)

func (*Server) Delete

func (*Server) Get

func (*Server) LeaderMonitor

func (*Server) ListenServer

func (s *Server) ListenServer() error

func (*Server) Lock

func (*Server) PrefixScan

func (*Server) RaftState

func (*Server) Set

func (*Server) TryLock

func (*Server) TrySet

func (*Server) Unlock

func (*Server) Watch

func (s *Server) Watch(req *serverpb.WatchRequest, stream serverpb.KV_WatchServer) error

type Snapshot

type Snapshot struct {
	io.Reader
}

func (*Snapshot) Persist

func (s *Snapshot) Persist(sink raft.SnapshotSink) error

func (*Snapshot) Release

func (s *Snapshot) Release()

type StableStore

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

func NewStableStore

func NewStableStore(s store.Store) (*StableStore, error)

func (*StableStore) Get

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

Get returns the value for key, or an empty byte slice if key was not found.

func (*StableStore) GetUint64

func (s *StableStore) GetUint64(key []byte) (uint64, error)

GetUint64 returns the uint64 value for key, or 0 if key was not found.

func (*StableStore) Set

func (s *StableStore) Set(key []byte, val []byte) error

func (*StableStore) SetUint64

func (s *StableStore) SetUint64(key []byte, val uint64) error

Directories

Path Synopsis
_bin
RedQueenServer command
RedQueenUtil command
api
internal

Jump to

Keyboard shortcuts

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