forked from hashicorp/raft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
42 lines (32 loc) · 884 Bytes
/
log.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package raft
type LogType uint8
const (
// Commands are applied to a user FSM
LogCommand LogType = iota
// Noop is used to assert leadership
LogNoop
// Used to add a new peer
LogAddPeer
// Used to remove an existing peer
LogRemovePeer
)
// Log entries are replicated to all members of the Raft cluster
// and form the heart of the replicated state machine.
type Log struct {
Index uint64
Term uint64
Type LogType
Data []byte
}
// LogStore is used to provide an interface for storing
// and retrieving logs in a durable fashion
type LogStore interface {
// Returns the last index written. 0 for no entries.
LastIndex() (uint64, error)
// Gets a log entry at a given index
GetLog(index uint64, log *Log) error
// Stores a log entry
StoreLog(log *Log) error
// Deletes a range of log entries. The range is inclusive.
DeleteRange(min, max uint64) error
}