start: add config struct for db path

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2025-12-11 21:43:48 +01:00
commit 568098af1d
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
3 changed files with 12 additions and 3 deletions

View file

@ -124,7 +124,11 @@ func printDB() {
}
func main() {
DB = kv.InitDB()
var conf kv.Config = kv.Config{
Path: "./data/",
}
DB = kv.InitDB(conf)
defer DB.Close()
printDB()

View file

@ -4,8 +4,8 @@ import (
"github.com/dgraph-io/badger/v4"
)
func InitDB() *badger.DB {
opts := badger.DefaultOptions("./data")
func InitDB(conf Config) *badger.DB {
opts := badger.DefaultOptions(conf.Path)
opts.Logger = nil
opts.ValueLogFileSize = 10 << 20 // 10 Mo par fichier vlog
opts.NumMemtables = 1

5
pkg/db/kv/struct.go Normal file
View file

@ -0,0 +1,5 @@
package kv
type Config struct {
Path string
}