package store import ( "sync" "git.aiterp.net/rpdata/api/internal/config" ) var initMuted sync.Mutex var hasInitialized bool // Init initalizes the store func Init() error { initMuted.Lock() defer initMuted.Unlock() if hasInitialized { return nil } conf := config.Global() dbconf := conf.Database err := ConnectDB(dbconf.Host, dbconf.Port, dbconf.Db, dbconf.Username, dbconf.Password, dbconf.Mechanism) if err != nil { return err } sconf := conf.Space if sconf.Enabled { err = ConnectSpace(sconf.Host, sconf.AccessKey, sconf.SecretKey, sconf.Bucket, sconf.MaxSize, sconf.Root) if err != nil { return err } } hasInitialized = true return nil }