feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
30
app/models/init.go
Обычный файл
30
app/models/init.go
Обычный файл
@@ -0,0 +1,30 @@
|
||||
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
|
||||
}
|
||||
Ссылка в новой задаче
Block a user