CoreInterface remodel, PluginRegistry added

This commit is contained in:
Darko Luketic
2019-01-16 05:48:01 +01:00
parent c9f3abd8b9
commit b722cb8a62
4 changed files with 265 additions and 33 deletions

153
core/base/base.go Normal file
View File

@ -0,0 +1,153 @@
package base
import (
"fmt"
"github.com/globalsign/mgo"
"github.com/jinzhu/gorm"
)
type Base struct{}
func (b *Base) Register() (string, error) {
if e := b.BeforeLoadPlugins(); e != nil {
return "", e
}
if e := b.LoadPlugins(); e != nil {
return "", e
}
if e := b.AfterLoadPlugins(); e != nil {
return "", e
}
if e := b.BeforeLoadConfiguration(); e != nil {
return "", e
}
if e := b.LoadConfiguration(); e != nil {
return "", e
}
if e := b.AfterLoadConfiguration(); e != nil {
return "", e
}
if e := b.BeforeConnectToDatabases(); e != nil {
return "", e
}
if e := b.ConnectToDatabases(); e != nil {
return "", e
}
if e := b.AfterConnectToDatabases(); e != nil {
return "", e
}
if e := b.BeforeSetupLogger(); e != nil {
return "", e
}
if e := b.SetupLogger(); e != nil {
return "", e
}
if e := b.AfterSetupLogger(); e != nil {
return "", e
}
if e := b.BeforeSetupRoutes(); e != nil {
return "", e
}
if e := b.SetupRoutes(); e != nil {
return "", e
}
if e := b.AfterSetupRoutes(); e != nil {
return "", e
}
if e := b.BeforeRun(); e != nil {
return "", e
}
if e := b.Run(); e != nil {
return "", e
}
if e := b.AfterRun(); e != nil {
return "", e
}
return "base", nil
}
func (b *Base) UnRegister() error {
return nil
}
func (b *Base) BeforeLoadPlugins() error {
fmt.Println("Hello World. BeforeLoadPlugins")
return nil
}
func (b *Base) LoadPlugins() error {
return nil
}
func (b *Base) AfterLoadPlugins() error {
return nil
}
func (b *Base) BeforeLoadConfiguration() error {
return nil
}
func (b *Base) LoadConfiguration() error {
return nil
}
func (b *Base) AfterLoadConfiguration() error {
return nil
}
func (b *Base) ConnectMongoDB(string) (*mgo.Session, error) {
return nil, nil
}
func (b *Base) ConnectGORM(string) (*gorm.DB, error) {
return nil, nil
}
func (b *Base) BeforeConnectToDatabases() error {
return nil
}
func (b *Base) ConnectToDatabases() error {
return nil
}
func (b *Base) AfterConnectToDatabases() error {
return nil
}
func (b *Base) BeforeSetupLogger() error {
return nil
}
func (b *Base) SetupLogger() error {
return nil
}
func (b *Base) AfterSetupLogger() error {
return nil
}
func (b *Base) BeforeSetupRoutes() error {
return nil
}
func (b *Base) SetupRoutes() error {
return nil
}
func (b *Base) AfterSetupRoutes() error {
return nil
}
func (b *Base) BeforeRun() error {
return nil
}
func (b *Base) Run() error {
return nil
}
func (b *Base) AfterRun() error {
return nil
}