chore(storage): support set db path for badger driver (#499)

* chore(storage): support set db path for badger driver

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* fix path

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* fix readme

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update default value

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2020-04-23 10:34:35 +08:00
committed by GitHub
parent ccc73947ad
commit 4e05611577
5 changed files with 26 additions and 6 deletions

View File

@@ -30,7 +30,12 @@ type Storage struct {
// Init client storage.
func (s *Storage) Init() error {
s.name = "badger"
s.opts = badger.DefaultOptions(os.TempDir() + "badger")
dbPath := s.config.Stat.BadgerDB.Path
if dbPath == "" {
dbPath = os.TempDir() + "badger"
}
s.opts = badger.DefaultOptions(dbPath)
return nil
}