func (s *MemoryStorage) Term(i uint64) (uint64, error) {
	term, err := s.memDB.Term(i)
	if err != nil {
		log.Log.Errorf("MemoryStorage:Term error,err:%s,i:%d",
			err.Error(), i)
		return 0, err
	}
	return term, nil
}
Term get raft term of raft index
package storage
import (
	"os"
	"github.com/coreos/etcd/raft"
	"github.com/coreos/etcd/raft/raftpb"
	"github.com/flike/kingbus/log"
	"github.com/flike/kingbus/utils"
)
type MemoryStorage struct {
	MetaStorage
	memDB *raft.MemoryStorage
}
func NewMemoryStorage(dir string) (*MemoryStorage, error) {
	var err error
	if len(dir) == 0 {
		return nil, ErrArgsIllegal
	}
	if utils.DirExist(dir) == false {
		err = os.MkdirAll(dir, DirMode)
		if err != nil {
			return nil, err
		}
	}
	s := new(MemoryStorage)
	s.memDB = raft.NewMemoryStorage()
	s.MetaStorage, err = NewMetaStore(dir)
	if err != nil {
		log.Log.Errorf("NewMemoryStorage:NewMetaStorage error,err:%s,dir:%s", err.Error(), dir)
		return nil, err
	}
	return s, nil
}
func (s *MemoryStorage) Entries(lo, hi, maxSize uint64) ([]raftpb.Entry, error) {
	entries, err := s.memDB.Entries(lo, hi, maxSize)
	if err != nil {
		log.Log.Errorf("MemoryStorage:entries error,err:%s,lo:%d,hi:%d,maxSize:%d",
			err.Error(), lo, hi, maxSize)
		return nil, err
	}
	return entries, nil
}