raftkv

package
v0.0.0-...-00b922a Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK       = "OK"
	ErrNoKey = "ErrNoKey"
	Abort    = "Abort"
)

Error Strings

View Source
const (
	Get = iota
	Put
	Append
)

Command Constants

View Source
const Debug = 0

Debug toggles print logs

View Source
const PrintBool = false

PrintBool toggles debugging logs

Variables

This section is empty.

Functions

func DPrintf

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

DPrintf prints logs for debugging

Types

type Clerk

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

Clerk struct for client

func MakeClerk

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

MakeClerk makes client

func (*Clerk) Append

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

Append calls PutAppend with Append

func (*Clerk) Get

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

Get RPC Call

func (*Clerk) Put

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

Put calls PutAppend with Put

func (*Clerk) PutAppend

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

PutAppend RPC Call

type GetArgs

type GetArgs struct {
	Key       string
	RequestID int64
	ClientID  int64
}

GetArgs args for Get RPC Call

type GetReply

type GetReply struct {
	WrongLeader bool
	Err         string
	Value       string
}

GetReply reply for Get RPC Call

type Op

type Op struct {
	Command   int
	Key       string
	Value     string
	RequestID int64
	ClientID  int64
	Result    string
	Err       string
	Index     int
}

Op passed to raft.go for processing

type PutAppendArgs

type PutAppendArgs struct {
	Key       string
	Value     string
	Op        string
	RequestID int64
	ClientID  int64
}

PutAppendArgs args for PutAppend RPC Call

type PutAppendReply

type PutAppendReply struct {
	WrongLeader bool
	Err         string
}

PutAppendReply reply for PutAppend RPC Call

type RaftKV

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

RaftKV struct for server

func StartKVServer

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

StartKVServer starts server

func (*RaftKV) Get

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

Get RPC Call

func (*RaftKV) Kill

func (kv *RaftKV) Kill()

Kill kills server

func (*RaftKV) PutAppend

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

PutAppend RPC Call

Jump to

Keyboard shortcuts

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