(dir string)
| 56 | } |
| 57 | |
| 58 | func NewDataStore(dir string) *DataStore { |
| 59 | snapshotDir := fmt.Sprintf("%s/snapshot", dir) |
| 60 | snapshotter := snap.New(logger.Get(), snapshotDir) |
| 61 | return &DataStore{ |
| 62 | walDir: fmt.Sprintf("%s/wal", dir), |
| 63 | snapshotDir: snapshotDir, |
| 64 | snapshotter: snapshotter, |
| 65 | raftStorage: raft.NewMemoryStorage(), |
| 66 | kvs: make(map[string][]byte), |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | func (ds *DataStore) walExists() bool { |
| 71 | return wal.Exist(ds.walDir) |