Files
glkvm-cloud/internal/store/sqlite/container.go
T
GL.iNet-Yongping.Xie 7931fa0efd fix: refactor legacy login endpoint
Refactor legacy login endpoint and keep compatibility with existing authentication logic.

Signed-off-by: GL.iNet-Yongping.Xie <yongping.xie@gl-inet.com>
2026-01-19 02:15:07 -08:00

32 lines
474 B
Go
Executable File

package sqlite
import (
"gorm.io/gorm"
"sync"
)
type Container struct {
Gorm *gorm.DB
DeviceMeta *DeviceMetaRepo
}
var (
gContainer *Container
mu sync.RWMutex
)
func SetContainer(c *Container) {
mu.Lock()
defer mu.Unlock()
gContainer = c
}
func MustContainer() *Container {
mu.RLock()
defer mu.RUnlock()
if gContainer == nil {
panic("sqlite container not initialized")
}
return gContainer
}