red

package module
v0.2.5-beta2 Latest Latest
Warning

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

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

README

RedQueen

Go Report Card CodeQL 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

This section is empty.

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 Command

type Command int32
const (
	SetWithTTL Command = iota
	TrySetWithTTL
	Set
	TrySet
	Del
)

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 LogPayload

type LogPayload struct {
	Command   Command `json:"command" msgpack:"cmd"`
	TTL       *uint32 `json:"ttl,omitempty" msgpack:"ttl,omitempty"`
	Namespace *string `json:"namespace,omitempty" msgpack:"ns,omitempty"`
	Key       []byte  `json:"key,omitempty" msgpack:"k,omitempty"`
	Value     []byte  `json:"value,omitempty" msgpack:"v,omitempty"`
}

type Raft

type Raft struct {
	*raft.Raft
}

func NewRaft

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

func (*Raft) AddCluster

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

type RaftConfig

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

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) 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