Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when the specified record is not saved. ErrNotFound = errors.New("not found") )
Functions ¶
func RegisterType ¶
func RegisterType(v interface{})
RegisterType will register the type with the raft log marshaller.
Types ¶
type Broadcaster ¶
type Broadcaster interface { // AddListener adds a new listener for changes. RegisterListener(listener Listener) }
Broadcaster defines the interface that a type must implement to broadcast changes.
type Command ¶
type Command int
Command is used to denote which operation should be carried out as a result of a Raft commit.
type IDSetter ¶
type IDSetter interface { SetID() GetID() string }
IDSetter is the interface required by all database write operations.
type Listener ¶
type Listener interface { // PostApply will be called in its own goroutine when the node detects // a change in the database. If leader is true the current node is // leader. PostApply(leader bool, command Command, data interface{}) }
Listener is an interface for type capable of listening to changes in the database.
type LogEntry ¶
type LogEntry struct { Command Command Type string Value json.RawMessage }
LogEntry is an entry in the Raft log (?).
func NewLogEntry ¶
NewLogEntry will return a new LogEntry ready for committing to the Raft log.
type Object ¶
type Object struct {
ID string `json:"id"`
}
Object can be embbed in other types for saving to the database and thereby easily implementing IDSetter.
type ReadWriteBroadcaster ¶
type ReadWriteBroadcaster interface { Reader Writer Broadcaster }
ReadWriteBroadcaster must be implemented by types able to both read, write and broadcast.
type ReadWriter ¶
ReadWriter must be implemented by types able to both read and write.
type Reader ¶
type Reader interface { // One will retrieve one record from the database. One(fieldName string, value interface{}, to interface{}) error // All lists all kinds of a type. All(to interface{}, limit int, skip int, reverse bool) error // Find Find returns one or more records by the specified index. Find(field string, value interface{}, to interface{}, limit int, skip int, reverse bool) error }
Reader defines the interface that database reader types must implement.