kvpaxos

package
v0.0.0-...-69bd5ce Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK         = "OK"
	ErrNoKey   = "ErrNoKey"
	ServerDead = "ServerDead"
)
View Source
const (
	GET     = "GET"
	PUT     = "PUT"
	PUTHASH = "PUTHASH"
)
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 {
	// contains filtered or unexported fields
}

func MakeClerk

func MakeClerk(servers []string) *Clerk

func (*Clerk) Get

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

fetch the current value for a key. returns "" if the key does not exist. keeps trying forever in the face of all other errors.

func (*Clerk) Put

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

func (*Clerk) PutExt

func (ck *Clerk) PutExt(key string, value string, dohash bool) string

set the value for a key. keeps trying until it succeeds.

func (*Clerk) PutHash

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

type Err

type Err string

type GetArgs

type GetArgs struct {
	Key string
	// You'll have to add definitions here.
	ReqId int64
}

type GetReply

type GetReply struct {
	Err   Err
	Value string
}

type KVPaxos

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

func StartServer

func StartServer(servers []string, me int) *KVPaxos

servers[] contains the ports of the set of servers that will cooperate via Paxos to form the fault-tolerant key/value service. me is the index of the current server in servers[].

func (*KVPaxos) Get

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

func (*KVPaxos) Put

func (kv *KVPaxos) Put(args *PutArgs, reply *PutReply) error

type Op

type Op struct {
	// Your definitions here.
	// Field names must start with capital letters,
	// otherwise RPC will break.
	Type       OpType
	Key, Value string
	ReqId      int64
}

type OpType

type OpType string

type PutArgs

type PutArgs struct {
	// You'll have to add definitions here.
	Key    string
	Value  string
	DoHash bool // For PutHash
	// You'll have to add definitions here.
	// Field names must start with capital letters,
	// otherwise RPC will break.
	ReqId int64
}

type PutReply

type PutReply struct {
	Err           Err
	PreviousValue string // For PutHash
}

Jump to

Keyboard shortcuts

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