Documentation ¶
Index ¶
- Variables
- type Config
- type DefaultLogger
- func (l *DefaultLogger) Debug(v ...interface{})
- func (l *DefaultLogger) Debugf(format string, v ...interface{})
- func (l *DefaultLogger) EnableDebug()
- func (l *DefaultLogger) Error(v ...interface{})
- func (l *DefaultLogger) Errorf(format string, v ...interface{})
- func (l *DefaultLogger) Fatal(v ...interface{})
- func (l *DefaultLogger) Fatalf(format string, v ...interface{})
- func (l *DefaultLogger) Info(v ...interface{})
- func (l *DefaultLogger) Infof(format string, v ...interface{})
- func (l *DefaultLogger) Panic(v ...interface{})
- func (l *DefaultLogger) Panicf(format string, v ...interface{})
- func (l *DefaultLogger) Warning(v ...interface{})
- func (l *DefaultLogger) Warningf(format string, v ...interface{})
- type Logger
- type MemoryStorage
- type Node
- type Ready
- type Storage
Constants ¶
This section is empty.
Variables ¶
var ( // ErrStopped is returned by methods on Nodes that have been stopped. ErrStopped = errors.New("epaxos: stopped") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // ID is the identity of the local epaxos. ID pb.ReplicaID // Nodes is the set of all nodes in the epaxos network. Nodes []pb.ReplicaID // Storage is the persistent storage for epaxos. epaxos reads out // the previous instance state and configuration from storage when // restarting. Storage Storage // Logger is the logger that the epaxos state machine will use // to log events. If not set, a default logger will be used. Logger Logger // RandSeed allows the seed used by epaxos's rand.Source to be // injected, to allow for fully deterministic execution. RandSeed int64 }
Config contains the parameters to start epaxos.
type DefaultLogger ¶
DefaultLogger is a default implementation of the Logger interface.
func NewDefaultLogger ¶
func NewDefaultLogger() *DefaultLogger
NewDefaultLogger creates a default logger that prints to stderr.
func (*DefaultLogger) Debug ¶
func (l *DefaultLogger) Debug(v ...interface{})
Debug implements the Logger interface.
func (*DefaultLogger) Debugf ¶
func (l *DefaultLogger) Debugf(format string, v ...interface{})
Debugf implements the Logger interface.
func (*DefaultLogger) EnableDebug ¶
func (l *DefaultLogger) EnableDebug()
EnableDebug enables debug messages to print.
func (*DefaultLogger) Error ¶
func (l *DefaultLogger) Error(v ...interface{})
Error implements the Logger interface.
func (*DefaultLogger) Errorf ¶
func (l *DefaultLogger) Errorf(format string, v ...interface{})
Errorf implements the Logger interface.
func (*DefaultLogger) Fatal ¶
func (l *DefaultLogger) Fatal(v ...interface{})
Fatal implements the Logger interface.
func (*DefaultLogger) Fatalf ¶
func (l *DefaultLogger) Fatalf(format string, v ...interface{})
Fatalf implements the Logger interface.
func (*DefaultLogger) Info ¶
func (l *DefaultLogger) Info(v ...interface{})
Info implements the Logger interface.
func (*DefaultLogger) Infof ¶
func (l *DefaultLogger) Infof(format string, v ...interface{})
Infof implements the Logger interface.
func (*DefaultLogger) Panic ¶
func (l *DefaultLogger) Panic(v ...interface{})
Panic implements the Logger interface.
func (*DefaultLogger) Panicf ¶
func (l *DefaultLogger) Panicf(format string, v ...interface{})
Panicf implements the Logger interface.
func (*DefaultLogger) Warning ¶
func (l *DefaultLogger) Warning(v ...interface{})
Warning implements the Logger interface.
func (*DefaultLogger) Warningf ¶
func (l *DefaultLogger) Warningf(format string, v ...interface{})
Warningf implements the Logger interface.
type Logger ¶
type Logger interface { Debug(v ...interface{}) Debugf(format string, v ...interface{}) Error(v ...interface{}) Errorf(format string, v ...interface{}) Info(v ...interface{}) Infof(format string, v ...interface{}) Warning(v ...interface{}) Warningf(format string, v ...interface{}) Fatal(v ...interface{}) Fatalf(format string, v ...interface{}) Panic(v ...interface{}) Panicf(format string, v ...interface{}) }
Logger provides a logging interface similar to golang's standard Logger.
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage implements the Storage interface backed by an in-memory data structure.
func (*MemoryStorage) HardState ¶
func (ms *MemoryStorage) HardState() (pb.HardState, bool)
HardState implements the Storage interface.
func (*MemoryStorage) Instances ¶
func (ms *MemoryStorage) Instances() []*pb.InstanceState
Instances implements the Storage interface.
func (*MemoryStorage) PersistHardState ¶
func (ms *MemoryStorage) PersistHardState(hs pb.HardState)
PersistHardState implements the Storage interface.
func (*MemoryStorage) PersistInstance ¶
func (ms *MemoryStorage) PersistInstance(is *pb.InstanceState)
PersistInstance implements the Storage interface.
type Node ¶
type Node interface { // Tick increments the internal logical clock for the Node by a single tick. // Election timeouts and progress timeouts are in units of ticks. Tick() // Propose proposes that data be ordered by paxos. Propose(ctx context.Context, command pb.Command) error // Step advances the state machine using the given message. ctx.Err() will be // returned, if any. Step(ctx context.Context, msg pb.Message) error // Ready returns a channel that returns the current point-in-time state. // Users of the Node must call Advance after retrieving the state returned by // Ready. // // NOTE: No committed entries from the next Ready may be applied until all // committed entries and snapshots from the previous one have finished. Ready() <-chan Ready // Stop performs any necessary termination of the Node. Stop() }
Node represents a node in a paxos cluster.
type Ready ¶
type Ready struct { // Messages specifies outbound messages to be sent AFTER Entries are // committed to stable storage. Messages []pb.Message // ExecutedCommands specifies commands to be executed by a state-machine. // These have previously been committed to stable store. ExecutedCommands []pb.Command }
Ready encapsulates the entries and messages that are ready to read, be saved to stable storage, committed or sent to other peers. All fields in Ready are read-only.
type Storage ¶
type Storage interface { HardState() (pb.HardState, bool) PersistHardState(hs pb.HardState) Instances() []*pb.InstanceState PersistInstance(is *pb.InstanceState) }
Storage allows for the persistence of EPaxos state to provide durability.
func NewMemoryStorage ¶
NewMemoryStorage returns a new in-memory implementation of Storage using the provided Config.