♻️ Refactor config
Make it easier to setup stores
This commit is contained in:
parent
ecae0d5f83
commit
6f06adc37d
12 changed files with 623 additions and 81 deletions
|
|
@ -10,8 +10,17 @@ func init() {
|
|||
store.AddFactory("sqlite", MakeStore)
|
||||
}
|
||||
|
||||
func MakeStore(conf config.Config) (store.Store, error) {
|
||||
sqlConf := sqlite.Config{Path: conf.Conn.DSN}
|
||||
type settings struct {
|
||||
Path string
|
||||
}
|
||||
|
||||
func MakeStore(conf config.Store) (store.Store, error) {
|
||||
var s settings
|
||||
err := conf.Decode(&s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sqlConf := sqlite.Config{Path: s.Path}
|
||||
db, err := sqlite.New(sqlConf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue