raftkv

package
v0.0.0-...-ab99748 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK       = "OK"
	ErrNoKey = "ErrNoKey"
)
View Source
const Debug = 0

Variables

This section is empty.

Functions

func DPrintf

func DPrintf(format string, a ...interface{}) (n int, err error)

Types

type Clerk

type Clerk struct {

	// You will have to modify this struct.
	Name int64
	Seq  int
	// contains filtered or unexported fields
}

func MakeClerk

func MakeClerk(servers []*labrpc.ClientEnd) *Clerk

func (*Clerk) Append

func (ck *Clerk) Append(key string, value string)

func (*Clerk) Get

func (ck *Clerk) Get(key string) string

func (*Clerk) Put

func (ck *Clerk) Put(key string, value string)

func (*Clerk) PutAppend

func (ck *Clerk) PutAppend(key string, value string, op string)

type Err

type Err string

type GetArgs

type GetArgs struct {
	Key  string
	Name int64
	Seq  int
}

type GetReply

type GetReply struct {
	WrongLeader bool
	Err         Err
	Value       string
}

type KVServer

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

func StartKVServer

func StartKVServer(servers []*labrpc.ClientEnd, me int, persister *raft.Persister, maxraftstate int) *KVServer

func (*KVServer) AppendEntryToLog

func (kv *KVServer) AppendEntryToLog(entry Op) bool

func (*KVServer) Apply

func (kv *KVServer) Apply(args Op)

func (*KVServer) Get

func (kv *KVServer) Get(args *GetArgs, reply *GetReply)

func (*KVServer) IsValid

func (kv *KVServer) IsValid(name int64, seq int) bool

func (*KVServer) Kill

func (kv *KVServer) Kill()

func (*KVServer) PutAppend

func (kv *KVServer) PutAppend(args *PutAppendArgs, reply *PutAppendReply)

type Op

type Op struct {
	Method string
	Key    string
	Value  string
	// Identify clients
	Name int64
	// Sequence number for every clients
	Seq int
}

type PutAppendArgs

type PutAppendArgs struct {
	Key   string
	Value string
	Op    string
	Name  int64
	Seq   int
}

Put or Append

type PutAppendReply

type PutAppendReply struct {
	WrongLeader bool
	Err         Err
}

Jump to

Keyboard shortcuts

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