raft_badger

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Raft-badger is a full implementation raft kv store based on badger

Source code info

  • log_store.go
raft log store based on badger
  • stable_store.go
stable log store based on badger ( for config)
  • fsm.go
fsm store based on badger ( for client)

Quick start

braftd

Documentation

Index

Constants

View Source
const (
	FsmCommandSet = "Set"
	FsmCommandDel = "Delete"
)
View Source
const (
	BucketSpliter = "@"
)

Variables

View Source
var (
	FsmBucket       = []byte("raft_fsm_") // raft fsmStore bucket
	FsmBucketLength = len(FsmBucket)
)
View Source
var (
	EmptyBucket []byte

	LogBucket       = []byte("raft_log_") // raft log
	LogBucketLength = len(LogBucket)
)
View Source
var (
	StableBucket       = []byte("raft_stable_") // raft stable log
	StableBucketLength = len(StableBucket)
)

Functions

func MKeys

func MKeys(m map[string]string) []string

func PrintMapDiff

func PrintMapDiff(baseKv, newKv map[string]string)

Types

type FsmCommand

type FsmCommand struct {
	Op    string `json:"op,omitempty"`
	Error error  `json:"-"` // only output, not input param,

	Bucket string            `json:"bucket,omitempty"` // check where to be used
	Kv     map[string]string `json:"kv,omitempty"`
}

type Peer

type Peer struct {
	Id       string
	RaftDir  string
	RaftBind string
	// contains filtered or unexported fields
}

func NewPeer

func NewPeer(id, dir, bind string) *Peer

func (*Peer) Close

func (p *Peer) Close() error

Close peer

func (*Peer) Delete

func (p *Peer) Delete(bucket, key string) error

Delete a kv on leader

func (*Peer) Get

func (p *Peer) Get(bucket, k string) (result string, found bool, e error)

Get a kv on any peer

func (*Peer) Join

func (p *Peer) Join(peerId, addr string) error

Join a raft cluster

func (*Peer) Keys

func (p *Peer) Keys(bucket string) (map[string]string, error)

Keys all in bucket

func (*Peer) KeysWithoutValues

func (p *Peer) KeysWithoutValues(bucket string) (keys []string, err error)

KeysWithoutValues in bucket

func (*Peer) MakeSureLeader

func (p *Peer) MakeSureLeader() error

MakeSureLeader user set, delete should on leader. no need to read

func (*Peer) Open

func (p *Peer) Open() (err error)

Open a peer, ready to do join or joined by other peers @localID peer id @exist is useful when @err is nil

func (*Peer) PDelete

func (p *Peer) PDelete(bucket string, keys []string) error

PDelete multi kv on leader, Non-atomic operation

func (*Peer) PGet

func (p *Peer) PGet(bucket string, keys []string) (map[string]string, error)

PGet multi keys' values on any peer

func (*Peer) PSet

func (p *Peer) PSet(bucket string, kv map[string]string) error

PSet multi kv on leader, Non-atomic operation

func (*Peer) Remove added in v0.0.2

func (p *Peer) Remove(peerId, addr string) error

Remove a peer

func (*Peer) Set

func (p *Peer) Set(bucket, k, v string) error

Set a kv on leader

func (*Peer) StartSingle added in v0.0.2

func (p *Peer) StartSingle() error

StartSingle raft peer

func (*Peer) Stats

func (p *Peer) Stats() map[string]string

applied_index:2 commit_index:2 fsm_pending:0 last_contact:0 last_log_index:2 last_log_term:2 last_snapshot_index:0 last_snapshot_term:0 latest_configuration:[{Suffrage:Voter ID:node0 Address:127.0.0.1:0}] latest_configuration_index:0 num_peers:0 protocol_version:3 protocol_version_max:3 protocol_version_min:0 snapshot_version_max:1 snapshot_version_min:0 state:Leader term:2

type Stats

type Stats struct {
}

Jump to

Keyboard shortcuts

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