kv

package
v0.0.0-...-b115306 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddPeerArgs

type AddPeerArgs struct {
	Endpoint string
}

AddPeerArgs RPC structure

type AddPeerReply

type AddPeerReply struct {
	WrongLeader bool
}

AddPeerReply RPC structure

type AddServerReq

type AddServerReq struct {
	Endpoint string
}

type GetArgs

type GetArgs struct {
	Key       string
	ClientID  int64
	RequestID int
}

GetArgs structure for Get Argument

type GetReply

type GetReply struct {
	WrongLeader bool
	Err         string
	Value       string
}

GetReply structure for Get Reply

type KV

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

KV structure that holds Raft instance

func StartKVServer

func StartKVServer(servers []*rpc.Client, me int, persister *raft.Persister, maxraftstate int, e *echo.Echo) *KV

StartKVServer return a RaftKV servers[] contains the ports of the set of servers that will cooperate via Raft to form the fault-tolerant key/value service. me is the index of the current server in servers[]. the k/v server should store snapshots with persister.SaveSnapshot(), and Raft should save its state (including log) with persister.SaveRaftState(). the k/v server should snapshot when Raft's saved state exceeds maxraftstate bytes, in order to allow Raft to garbage-collect its log. if maxraftstate is -1, you don't need to snapshot. StartKVServer() must return quickly, so it should start goroutines for any long-running work.

func (*KV) AddPeer

func (kv *KV) AddPeer(args *AddPeerArgs, reply *AddPeerReply) error

func (*KV) AppendEntry

func (kv *KV) AppendEntry(entry Op) bool

AppendEntry appends an entry Op and returns a boolean

func (*KV) Get

func (kv *KV) Get(args *GetArgs, reply *GetReply) error

Get RPC

func (*KV) Kill

func (kv *KV) Kill()

Kill is called by the tester when a RaftKV instance won't be needed again. you are not required to do anything in Kill, but it might be convenient to (for example) turn off debug output from this instance.

func (*KV) PutAppend

func (kv *KV) PutAppend(args *PutAppendArgs, reply *PutAppendReply) error

PutAppend RPC

type Op

type Op struct {
	Type      string
	Key       string
	Value     string
	ClientID  int64
	RequestID int
}

Op structure

type PutAppendArgs

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

PutAppendArgs structure for Put or Append Argument

type PutAppendReply

type PutAppendReply struct {
	WrongLeader bool
	Err         string
}

PutAppendReply structure for Put or Append Reply

Jump to

Keyboard shortcuts

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