Esempio n. 1
0
func (c *CompressCommand) Apply(context raft.Context) (interface{}, error) {
	server := context.Server()
	db := server.Context().(*DB)

	db.Compress(c.Start, c.Stop)

	return new(interface{}), nil
}
Esempio n. 2
0
func (c *EventsCommand) Apply(context raft.Context) (interface{}, error) {
	server := context.Server()
	db := server.Context().(*DB)

	index := context.CurrentIndex()

	err := db.WriteAll(index, c.Bodies, c.Indexes, c.Timestamp)

	if err == nil && db.Offset() > db.RotateThreshold {
		err = db.Rotate(index, context.CurrentTerm())
		if err != nil {
			log.Fatal(err)
		}
	}

	return new(interface{}), err
}