mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-10-31 16:05:06 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			40 lines
		
	
	
		
			778 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			778 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package graph
 | |
| 
 | |
| import (
 | |
| 	"sync"
 | |
| 
 | |
| 	"github.com/ClusterCockpit/cc-backend/internal/repository"
 | |
| 	cclog "github.com/ClusterCockpit/cc-lib/ccLogger"
 | |
| 	"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 {
 | |
| 		cclog.Fatal("Authentication module not initialized!")
 | |
| 	}
 | |
| 
 | |
| 	return resolverInstance
 | |
| }
 |