refactor: init doesn't need portal passed

This commit is contained in:
Derrick Hammer 2024-01-19 12:43:16 -05:00
parent 8044591697
commit 5b6084986f
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 4 additions and 6 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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
} }