Skip to content

Commit

Permalink
feat: support badger.path in consensus (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgkawell authored Aug 9, 2024
1 parent 160dea6 commit 1af42c4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/chassis/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ func (c *Runtime) bootstrapRaft(registrar ConsensusRegistrar) {
raftConf.SnapshotThreshold = 1024

// set the path to the directory bolt will use to write to the filesystem
store, err := raftboltdb.NewBoltStore(filepath.Join(raftNodeID, "raft.dataRepo"))
basePath := c.config.GetString("badger.path")
if basePath == "" {
basePath = raftNodeID
}
store, err := raftboltdb.NewBoltStore(filepath.Join(basePath, "raft.dataRepo"))
if err != nil {
c.logger.Fatal(err.Error())
}
Expand All @@ -107,7 +111,7 @@ func (c *Runtime) bootstrapRaft(registrar ConsensusRegistrar) {
}

// TODO -> understand this more when diving into snapshots, and how they can be used to recover data
snapshotStore, err := raft.NewFileSnapshotStore(raftNodeID, raftSnapShotRetain, os.Stdout)
snapshotStore, err := raft.NewFileSnapshotStore(basePath, raftSnapShotRetain, os.Stdout)
if err != nil {
c.logger.Fatal(err.Error())
}
Expand Down

0 comments on commit 1af42c4

Please sign in to comment.