Documentation ¶
Index ¶
- Variables
- func RegisterPaxosKVServer(s *grpc.Server, srv PaxosKVServer)
- func ServeAcceptors(acceptorIds []int64) []*grpc.Server
- type Acceptor
- func (*Acceptor) Descriptor() ([]byte, []int)deprecated
- func (x *Acceptor) GetLastBal() *BallotNum
- func (x *Acceptor) GetVBal() *BallotNum
- func (x *Acceptor) GetVal() *Value
- func (*Acceptor) ProtoMessage()
- func (x *Acceptor) ProtoReflect() protoreflect.Message
- func (x *Acceptor) Reset()
- func (x *Acceptor) String() string
- type BallotNum
- func (*BallotNum) Descriptor() ([]byte, []int)deprecated
- func (a *BallotNum) GE(b *BallotNum) bool
- func (x *BallotNum) GetN() int64
- func (x *BallotNum) GetProposerId() int64
- func (*BallotNum) ProtoMessage()
- func (x *BallotNum) ProtoReflect() protoreflect.Message
- func (x *BallotNum) Reset()
- func (x *BallotNum) String() string
- type KVServer
- type PaxosInstanceId
- func (*PaxosInstanceId) Descriptor() ([]byte, []int)deprecated
- func (x *PaxosInstanceId) GetKey() string
- func (x *PaxosInstanceId) GetVer() int64
- func (*PaxosInstanceId) ProtoMessage()
- func (x *PaxosInstanceId) ProtoReflect() protoreflect.Message
- func (x *PaxosInstanceId) Reset()
- func (x *PaxosInstanceId) String() string
- type PaxosKVClient
- type PaxosKVServer
- type Proposer
- func (*Proposer) Descriptor() ([]byte, []int)deprecated
- func (x *Proposer) GetBal() *BallotNum
- func (x *Proposer) GetId() *PaxosInstanceId
- func (x *Proposer) GetVal() *Value
- func (p *Proposer) Phase1(acceptorIds []int64, quorum int) (*Value, *BallotNum, error)
- func (p *Proposer) Phase2(acceptorIds []int64, quorum int) (*BallotNum, error)
- func (*Proposer) ProtoMessage()
- func (x *Proposer) ProtoReflect() protoreflect.Message
- func (x *Proposer) Reset()
- func (p *Proposer) RunPaxos(acceptorIds []int64, val *Value) *Value
- func (x *Proposer) String() string
- type UnimplementedPaxosKVServer
- type Value
- type Version
- type Versions
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoEnoughQuorum = errors.New("no enough quorum") AcceptorBasePort = 3333 )
var File_api_paxos_proto protoreflect.FileDescriptor
Functions ¶
func RegisterPaxosKVServer ¶
func RegisterPaxosKVServer(s *grpc.Server, srv PaxosKVServer)
func ServeAcceptors ¶
ServeAcceptors starts a gRPC server for every acceptor.
Types ¶
type Acceptor ¶
type Acceptor struct { // the last ballot number the instance knows of. LastBal *BallotNum `protobuf:"bytes,1,opt,name=lastBal,proto3" json:"lastBal,omitempty"` // the voted value by this Acceptor. Val *Value `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"` // the ballot number the Acceptor voted it. VBal *BallotNum `protobuf:"bytes,3,opt,name=VBal,proto3" json:"VBal,omitempty"` // contains filtered or unexported fields }
Acceptor is the state of an Acceptor and also serves as the reply of Prepare/Accept.
func (*Acceptor) Descriptor
deprecated
func (*Acceptor) GetLastBal ¶
func (*Acceptor) ProtoMessage ¶
func (*Acceptor) ProtoMessage()
func (*Acceptor) ProtoReflect ¶
func (x *Acceptor) ProtoReflect() protoreflect.Message
type BallotNum ¶
type BallotNum struct { N int64 `protobuf:"varint,1,opt,name=N,proto3" json:"N,omitempty"` ProposerId int64 `protobuf:"varint,2,opt,name=ProposerId,proto3" json:"ProposerId,omitempty"` // contains filtered or unexported fields }
BallotNum is the ballot number in paxos. It consists of a monotonically incremental number and a university unique ProposerId.
func (*BallotNum) Descriptor
deprecated
func (*BallotNum) GetProposerId ¶
func (*BallotNum) ProtoMessage ¶
func (*BallotNum) ProtoMessage()
func (*BallotNum) ProtoReflect ¶
func (x *BallotNum) ProtoReflect() protoreflect.Message
type KVServer ¶
KVServer implements the paxos Acceptor API, handling Prepare and Accept request.
type PaxosInstanceId ¶
type PaxosInstanceId struct { // the key of the record to operate on. Key string `protobuf:"bytes,1,opt,name=Key,proto3" json:"Key,omitempty"` // the version of the record to modify. Ver int64 `protobuf:"varint,2,opt,name=Ver,proto3" json:"Ver,omitempty"` // contains filtered or unexported fields }
PaxosInstanceId specifies which paxos instance it runs on. A paxos instance is used to determine a specific version of a record.
func (*PaxosInstanceId) Descriptor
deprecated
func (*PaxosInstanceId) Descriptor() ([]byte, []int)
Deprecated: Use PaxosInstanceId.ProtoReflect.Descriptor instead.
func (*PaxosInstanceId) GetKey ¶
func (x *PaxosInstanceId) GetKey() string
func (*PaxosInstanceId) GetVer ¶
func (x *PaxosInstanceId) GetVer() int64
func (*PaxosInstanceId) ProtoMessage ¶
func (*PaxosInstanceId) ProtoMessage()
func (*PaxosInstanceId) ProtoReflect ¶
func (x *PaxosInstanceId) ProtoReflect() protoreflect.Message
func (*PaxosInstanceId) Reset ¶
func (x *PaxosInstanceId) Reset()
func (*PaxosInstanceId) String ¶
func (x *PaxosInstanceId) String() string
type PaxosKVClient ¶
type PaxosKVClient interface { Prepare(ctx context.Context, in *Proposer, opts ...grpc.CallOption) (*Acceptor, error) Accept(ctx context.Context, in *Proposer, opts ...grpc.CallOption) (*Acceptor, error) }
PaxosKVClient is the client API for PaxosKV service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewPaxosKVClient ¶
func NewPaxosKVClient(cc grpc.ClientConnInterface) PaxosKVClient
type PaxosKVServer ¶
type PaxosKVServer interface { Prepare(context.Context, *Proposer) (*Acceptor, error) Accept(context.Context, *Proposer) (*Acceptor, error) }
PaxosKVServer is the server API for PaxosKV service.
type Proposer ¶
type Proposer struct { // which paxos instance it runs on. Id *PaxosInstanceId `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` // the ballot number of a Proposer. Bal *BallotNum `protobuf:"bytes,2,opt,name=Bal,proto3" json:"Bal,omitempty"` // the value of a Proposer has chosen. Val *Value `protobuf:"bytes,3,opt,name=Val,proto3" json:"Val,omitempty"` // contains filtered or unexported fields }
Proposer is the state of a Proposer and also serves as the request of Prepare/Accept.
func (*Proposer) Descriptor
deprecated
func (*Proposer) GetId ¶
func (x *Proposer) GetId() *PaxosInstanceId
func (*Proposer) Phase1 ¶
Phase1 runs paxos phase-1 on the specified acceptorIds. If a higher ballot number is seen and phase-1 failed to constitute a quorum, the highest ballot and a ErrNoEnoughQuorum will be returned.
func (*Proposer) Phase2 ¶
Phase2 runs paxos phase-2 on the specified acceptorIds. If a higher ballot number is seen and phase-1 failed to constitute a quorum, the highest ballot and a ErrNoEnoughQuorum will be returned.
func (*Proposer) ProtoMessage ¶
func (*Proposer) ProtoMessage()
func (*Proposer) ProtoReflect ¶
func (x *Proposer) ProtoReflect() protoreflect.Message
type UnimplementedPaxosKVServer ¶
type UnimplementedPaxosKVServer struct { }
UnimplementedPaxosKVServer can be embedded to have forward compatible implementations.
type Value ¶
type Value struct { Vi64 int64 `protobuf:"varint,1,opt,name=Vi64,proto3" json:"Vi64,omitempty"` // contains filtered or unexported fields }
Value is the value part of a key-value record.
func (*Value) Descriptor
deprecated
func (*Value) ProtoMessage ¶
func (*Value) ProtoMessage()
func (*Value) ProtoReflect ¶
func (x *Value) ProtoReflect() protoreflect.Message