Documentation
¶
Overview ¶
Package finn provide a fast and simple Raft implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnknownCommand is returned when the command is not known. ErrUnknownCommand = errors.New("unknown command") // ErrWrongNumberOfArguments is returned when the number of arguments is wrong. ErrWrongNumberOfArguments = errors.New("wrong number of arguments") // ErrDisabled is returned when a feature is disabled. ErrDisabled = errors.New("disabled") )
Functions ¶
This section is empty.
Types ¶
type Applier ¶
type Applier interface {
// Apply applies a command
Apply(conn redcon.Conn, cmd redcon.Command,
mutate func() (interface{}, error),
respond func(interface{}) (interface{}, error),
) (interface{}, error)
Log() Logger
}
Applier is used to apply raft commands.
type Level ¶
type Level int
Level is for defining the raft consistency level.
const ( // Low is "low" consistency. All readonly commands will can processed by // any node. Very fast but may have stale reads. Low Level = -1 // Medium is "medium" consistency. All readonly commands can only be // processed by the leader. The command is not processed through the // raft log, therefore a very small (microseconds) chance for a stale // read is possible when a leader change occurs. Fast but only the leader // handles all reads and writes. Medium Level = 0 // High is "high" consistency. All commands go through the raft log. // Not as fast because all commands must pass through the raft log. High Level = 1 )
type Logger ¶
type Logger interface {
// Printf write notice messages
Printf(format string, args ...interface{})
// Verbosef writes verbose messages
Verbosef(format string, args ...interface{})
// Noticef writes notice messages
Noticef(format string, args ...interface{})
// Warningf write warning messages
Warningf(format string, args ...interface{})
// Debugf writes debug messages
Debugf(format string, args ...interface{})
}
Logger is a logger
type Machine ¶
type Machine interface {
// Command is called by the Node for incoming commands.
Command(a Applier, conn redcon.Conn, cmd redcon.Command) (interface{}, error)
// Restore is used to restore data from a snapshot.
Restore(rd io.Reader) error
// Snapshot is used to support log compaction. This call should write a
// snapshot to the provided writer.
Snapshot(wr io.Writer) error
}
Machine handles raft commands and raft snapshotting.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a Raft server node.
type Options ¶
type Options struct {
// Consistency is the raft consistency level for reads.
// Default is Medium
Consistency Level
// Durability is the fsync durability for disk writes.
// Default is Medium
Durability Level
// Backend is the database backend.
// Default is MemLog
Backend Backend
// LogLevel is the log verbosity
// Default is Notice
LogLevel LogLevel
// LogOutput is the log writer
// Default is os.Stderr
LogOutput io.Writer
// Accept is an optional function that can be used to
// accept or deny a connection. It fires when new client
// connections are created.
// Return false to deny the connection.
ConnAccept func(redcon.Conn) bool
// ConnClosed is an optional function that fires
// when client connections are closed.
// If there was a network error, then the error will be
// passed in as an argument.
ConnClosed func(redcon.Conn, error)
}
Options are used to provide a Node with optional functionality.
Click to show internal directories.
Click to hide internal directories.