refactor: init doesn't need portal passed
This commit is contained in:
parent
8044591697
commit
5b6084986f
|
@ -80,9 +80,7 @@ func initProtocols(p interfaces.Portal) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initStorage(p interfaces.Portal) error {
|
func initStorage(p interfaces.Portal) error {
|
||||||
p.Storage().Init()
|
return p.Storage().Init()
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func initAPI(p interfaces.Portal) error {
|
func initAPI(p interfaces.Portal) error {
|
||||||
|
|
4
db/db.go
4
db/db.go
|
@ -26,7 +26,7 @@ func NewDatabase(p interfaces.Portal) interfaces.Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init initializes the database connection
|
// Init initializes the database connection
|
||||||
func (d *DatabaseImpl) Init(p interfaces.Portal) error {
|
func (d *DatabaseImpl) Init() error {
|
||||||
// Retrieve DB config from Viper
|
// Retrieve DB config from Viper
|
||||||
username := viper.GetString("core.db.username")
|
username := viper.GetString("core.db.username")
|
||||||
password := viper.GetString("core.db.password")
|
password := viper.GetString("core.db.password")
|
||||||
|
@ -41,7 +41,7 @@ func (d *DatabaseImpl) Init(p interfaces.Portal) error {
|
||||||
// Open DB connection
|
// Open DB connection
|
||||||
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.Logger().Error("Failed to connect to database", zap.Error(err))
|
d.portal.Logger().Error("Failed to connect to database", zap.Error(err))
|
||||||
}
|
}
|
||||||
d.db = db
|
d.db = db
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package interfaces
|
||||||
import "gorm.io/gorm"
|
import "gorm.io/gorm"
|
||||||
|
|
||||||
type Database interface {
|
type Database interface {
|
||||||
Init(p Portal) error
|
Init() error
|
||||||
Start() error
|
Start() error
|
||||||
Get() *gorm.DB
|
Get() *gorm.DB
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue