♻️ Refactor config

Make it easier to setup stores
This commit is contained in:
Dan Jones 2025-01-26 20:07:45 -06:00
commit 6f06adc37d
12 changed files with 623 additions and 81 deletions

View file

@ -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