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 {
|
||||
p.Storage().Init()
|
||||
|
||||
return nil
|
||||
return p.Storage().Init()
|
||||
}
|
||||
|
||||
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
|
||||
func (d *DatabaseImpl) Init(p interfaces.Portal) error {
|
||||
func (d *DatabaseImpl) Init() error {
|
||||
// Retrieve DB config from Viper
|
||||
username := viper.GetString("core.db.username")
|
||||
password := viper.GetString("core.db.password")
|
||||
|
@ -41,7 +41,7 @@ func (d *DatabaseImpl) Init(p interfaces.Portal) error {
|
|||
// Open DB connection
|
||||
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
||||
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
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package interfaces
|
|||
import "gorm.io/gorm"
|
||||
|
||||
type Database interface {
|
||||
Init(p Portal) error
|
||||
Init() error
|
||||
Start() error
|
||||
Get() *gorm.DB
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue