Documentation ¶
Index ¶
Constants ¶
const ( Naive writeMethod = iota Syncr Batch Catastrophic )
Indexes of each different handler implementation.
const ( // Serialized logs commands as []byte to maximize command interpretation during // state recovery. Serialized logClass = iota // Recov is a minimal log format, stores just operation and operands following // the same kvstore message syntax, e.g.: // "set-X-Y" // Recov // Verbose is a more complex record syntax, containing most fields of the command // struct, e.g.: // "LogIndex | Operation | comments | IP" // Verbose // Stamped is the same as verbose class, but with a timestamp as sufix. Stamped )
Variables ¶
var DefaultConfig = &Config{ Class: Recov, Sync: true, Batch: 10, PerstWrites: false, }
DefaultConfig provides a Config with default values.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct { Id uint64 `json:"id,omitempty"` Ip string `json:"ip,omitempty"` Op Operation `json:"cmd,omitempty"` Comment string `json:"comment,omitempty"` }
A Command represents the records saved on log file.
type Config ¶
type Config struct { Class logClass Batch uint32 Sync bool // Used in catastrophic fault models, where crash faults must be recoverable even if // all nodes presented in the consensus cluster are down. Always set to false in any // other cases, because this strong assumption greatly degradates performance. PerstWrites bool }
Config provides any necessary configuration for journey.
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log struct for now just stores the chosen handler option
TODO: Instantiate alternative datastructures to optimize logging performance on command recording (less application overhead), or automatic command trimming from log file (reduced recovery time).
e.g.: DAG's for dependency tracking
func New ¶
New function instantiates a new logger with default handler and configured by Config struct.
func (*Log) Close ¶
func (l *Log) Close()
Close calls the handler deconstructor, that releases file descriptor and writes remaining buffered commands to stable storage.
func (*Log) PutJSON ¶
PutJSON writes a JSON serialized command into log. Unmarshaling it for more verbosed writing.
type Logger ¶
type Logger interface { // Append a protobuff serialized command into the log. Put(command []byte) // Append a JSON serialized command into the log. PutJSON(command []byte) // Classical insert, just append a new record on the file PutFormat(id int, op Operation, comment string, timeStamp string) // Returns a record with the corresponding id (not removing it) Get(id uint64) // Produces a compressed log for state-recover based on application semantics and dependency // tracking. The interpretation of the compressed log is equivalent to the original in terms // of safety, but quicker. Reduce() // Log desconstructor. Close() }
Logger is the interface that log implements