Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
28
services/gateway/sloppy/db.go
Normal file
28
services/gateway/sloppy/db.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package sloppy
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"fiskerinc.com/modules/db"
|
||||
"fiskerinc.com/modules/db/queries"
|
||||
"fiskerinc.com/modules/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
carsDB queries.CarsInterface
|
||||
carsDBOnce sync.Once
|
||||
)
|
||||
|
||||
func GetCarsDB() queries.CarsInterface {
|
||||
carsDBOnce.Do(func() {
|
||||
if carsDB != nil {
|
||||
return
|
||||
}
|
||||
client := &db.DBClient{}
|
||||
logger.Debug().Msg("Init Cars instance")
|
||||
cars := &queries.Cars{}
|
||||
cars.SetClient(client)
|
||||
carsDB = cars
|
||||
})
|
||||
return carsDB
|
||||
}
|
||||
Reference in New Issue
Block a user