pbservice

package
v0.0.0-...-6e43502 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK             = "OK"
	ErrNoKey       = "ErrNoKey"
	ErrWrongServer = "ErrWrongServer"
)
View Source
const (
	PUT    = "Put"
	APPEND = "Append"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Clerk

type Clerk struct {

	// Your declarations here
	Primary string
	// contains filtered or unexported fields
}

func MakeClerk

func MakeClerk(vshost string, me string) *Clerk

func (*Clerk) Append

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

tell the primary to append to key's value. must keep trying until it succeeds.

func (*Clerk) Get

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

fetch a key's value from the current primary; if they key has never been set, return "". Get() must keep trying until it either the primary replies with the value or the primary says the key doesn't exist (has never been Put().

func (*Clerk) Put

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

tell the primary to update key's value. must keep trying until it succeeds.

func (*Clerk) PutAppend

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

send a Put or Append RPC

func (*Clerk) RefreshPrimary

func (ck *Clerk) RefreshPrimary()

type Err

type Err string

type GetArgs

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

type GetReply

type GetReply struct {
	Err   Err
	Value string
}

type PBServer

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

func StartServer

func StartServer(vshost string, me string) *PBServer

func (*PBServer) Get

func (pb *PBServer) Get(args *GetArgs, reply *GetReply) error

func (*PBServer) PutAppend

func (pb *PBServer) PutAppend(args *PutAppendArgs, reply *PutAppendReply) error

func (*PBServer) TransferAll

func (pb *PBServer) TransferAll(args *TransferAllArgs, reply *TransferAllReply) error

func (*PBServer) TransferToBackup

func (pb *PBServer) TransferToBackup()

type PutAppendArgs

type PutAppendArgs struct {
	Key   string
	Value string
	// You'll have to add definitions here.
	Type   string //PUT/APPEND
	RandID int64  //随机数
	Direct bool   //primary转发or直接请求

}

Put or Append

type PutAppendReply

type PutAppendReply struct {
	Err Err
}

type TransferAllArgs

type TransferAllArgs struct {
	KVs map[string]string
	IDs map[int64]bool
}

type TransferAllReply

type TransferAllReply struct {
	Err Err
}

Jump to

Keyboard shortcuts

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