Exemple #1
0
func mustUnmarshalState(d []byte) raftpb.State {
	var s raftpb.State
	if err := s.Unmarshal(d); err != nil {
		panic(err)
	}
	return s
}
Exemple #2
0
func (w *WAL) SaveState(s *raftpb.State) error {
	log.Printf("path=%s wal.saveState state=\"%+v\"", w.f.Name(), s)
	b, err := s.Marshal()
	if err != nil {
		panic(err)
	}
	rec := &walpb.Record{Type: stateType, Data: b}
	return w.encoder.encode(rec)
}