Documentation ¶
Overview ¶
Package twopc is two phase commit implements for key-value store
Index ¶
- Variables
- func NewConsensus(serverAddr string) (transparent.Layer, error)
- type Coodinator
- type Participant
- func (a *Participant) Request(operation *transparent.Message) (*transparent.Message, error)
- func (a *Participant) SetCallback(committer func(m *transparent.Message) (*transparent.Message, error)) error
- func (a *Participant) SetTimeout(millisecond time.Duration)
- func (a *Participant) Start() error
- func (a *Participant) Stop() error
Constants ¶
This section is empty.
Variables ¶
View Source
var DebugLevel int
DebugLevel determine the amount of debug output
Functions ¶
func NewConsensus ¶
func NewConsensus(serverAddr string) (transparent.Layer, error)
NewConsensus returns Two phase commit consensus layer
Types ¶
type Coodinator ¶
type Coodinator struct {
// contains filtered or unexported fields
}
Coodinator distribute vote request
func NewCoodinator ¶
func NewCoodinator(serverAddr string) (*Coodinator, error)
NewCoodinator returns started Coodinator
func (*Coodinator) Connection ¶
func (c *Coodinator) Connection(stream pb.Cluster_ConnectionServer) error
Connection start and keep connection for each client
func (*Coodinator) Set ¶
func (c *Coodinator) Set(ctx context.Context, req *pb.SetRequest) (*pb.EmptyMessage, error)
Set accepts request from any client
func (*Coodinator) SetTimeout ¶
func (c *Coodinator) SetTimeout(millisecond time.Duration)
SetTimeout change timeout default is 1000 milliseconds
type Participant ¶
type Participant struct {
// contains filtered or unexported fields
}
Participant manage its resource
func NewParticipant ¶
func NewParticipant(serverAddr string) *Participant
NewParticipant returns started Participant
func (*Participant) Request ¶
func (a *Participant) Request(operation *transparent.Message) (*transparent.Message, error)
Request send request to Coodinator
func (*Participant) SetCallback ¶
func (a *Participant) SetCallback(committer func(m *transparent.Message) (*transparent.Message, error)) error
func (*Participant) SetTimeout ¶
func (a *Participant) SetTimeout(millisecond time.Duration)
SetTimeout change timeout default is 1000 milliseconds
func (*Participant) Start ¶
func (a *Participant) Start() error
func (*Participant) Stop ¶
func (a *Participant) Stop() error
Click to show internal directories.
Click to hide internal directories.