mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-25 21:09:05 +01:00
Jan Eitzinger
801607fc16
Convert components to Singletons Restructure main package Reduce dependencies
40 lines
773 B
Go
40 lines
773 B
Go
package graph
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/ClusterCockpit/cc-backend/internal/repository"
|
|
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
|
"github.com/jmoiron/sqlx"
|
|
)
|
|
|
|
// This file will not be regenerated automatically.
|
|
//
|
|
// It serves as dependency injection for your app, add any dependencies you require here.
|
|
var (
|
|
initOnce sync.Once
|
|
resolverInstance *Resolver
|
|
)
|
|
|
|
type Resolver struct {
|
|
DB *sqlx.DB
|
|
Repo *repository.JobRepository
|
|
}
|
|
|
|
func Init() {
|
|
initOnce.Do(func() {
|
|
db := repository.GetConnection()
|
|
resolverInstance = &Resolver{
|
|
DB: db.DB, Repo: repository.GetJobRepository(),
|
|
}
|
|
})
|
|
}
|
|
|
|
func GetResolverInstance() *Resolver {
|
|
if resolverInstance == nil {
|
|
log.Fatal("Authentication module not initialized!")
|
|
}
|
|
|
|
return resolverInstance
|
|
}
|