add dbpath config

This commit is contained in:
siddontang 2014-09-15 22:42:15 +08:00
parent 39d6db56bd
commit 95cbcc6460
4 changed files with 12 additions and 1 deletions

View File

@ -50,6 +50,7 @@ type Config struct {
DataDir string `toml:"data_dir"`
DBName string `toml:"db_name"`
DBPath string `toml:"db_path"`
LevelDB LevelDBConfig `toml:"leveldb"`

View File

@ -27,6 +27,9 @@ slaveof = ""
#
db_name = "leveldb"
# if not set, use data_dir/"db_name"_data
db_path = ""
[leveldb]
compression = false
block_size = 32768

View File

@ -29,6 +29,9 @@ slaveof = ""
#
db_name = "leveldb"
# if not set, use data_dir/"db_name"_data
db_path = ""
[leveldb]
compression = false
block_size = 32768

View File

@ -16,8 +16,12 @@ import (
)
func getStorePath(cfg *config.Config) string {
if len(cfg.DBPath) > 0 {
return cfg.DBPath
} else {
return path.Join(cfg.DataDir, fmt.Sprintf("%s_data", cfg.DBName))
}
}
func Open(cfg *config.Config) (*DB, error) {
s, err := driver.GetStore(cfg)