func()

in store/engine/raft/store.go [191:211]


func (ds *DataStore) applyDataEntry(entry raftpb.Entry) error {
	if entry.Type != raftpb.EntryNormal || len(entry.Data) == 0 {
		return nil
	}

	var e Event
	if err := json.Unmarshal(entry.Data, &e); err != nil {
		return err
	}
	switch e.Op {
	case opSet:
		ds.Set(e.Key, e.Value)
	case opDelete:
		ds.Delete(e.Key)
	case opGet:
		// do nothing
	default:
		return fmt.Errorf("unknown operation type: %d", e.Op)
	}
	return nil
}