Files
worker/app/models/init.go
Gleb Tv 2c7a0236da feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
2026-07-13 17:55:14 +03:00

31 строка
450 B
Go

package models
import (
"context"
"github.com/fatih/structs"
"gorm.io/gorm"
)
func init() {
structs.DefaultTagName = "json"
}
// db Gorm DB
var db *gorm.DB
// DB provides functionality.
func DB() *gorm.DB {
return db.WithContext(context.TODO())
}
// SetDB provides functionality.
func SetDB(newDb *gorm.DB) {
db = newDb
}
// IsDBAvailable returns true if the database has been initialized
func IsDBAvailable() bool {
return db != nil
}