graceful shutdown, CoreInterface changes, MongoDB official driver is the only DB backend

This commit is contained in:
Darko Luketic
2020-05-06 01:49:46 +02:00
parent b722cb8a62
commit 58609926b9
6 changed files with 277 additions and 175 deletions

View File

@ -1,9 +1,6 @@
package main
import (
"github.com/globalsign/mgo"
"github.com/jinzhu/gorm"
)
import "go.mongodb.org/mongo-driver/mongo"
type CoreInterface interface {
Register() (string, error)
@ -17,20 +14,9 @@ type CoreInterface interface {
LoadConfiguration() error
AfterLoadConfiguration() error
// connection string parameter e.g. "localhost"
ConnectMongoDB(string) (*mgo.Session, error)
// connection string parameter
ConnectGORM(string) (*gorm.DB, error)
// ConnectNeo4j
// ConnectArangoDB
// ConnectCassandra
// ConnectDGraph
BeforeConnectToDatabases() error
ConnectToDatabases() error
AfterConnectToDatabases() error
BeforeDatabaseInit() error
DatabaseInit() error
AfterDatabaseInit() error
BeforeSetupLogger() error
SetupLogger() error
@ -43,6 +29,14 @@ type CoreInterface interface {
BeforeRun() error
Run() error
AfterRun() error
BeforeShutdown() error
Shutdown() error
}
type DatabaseInterface interface {
Client() *mongo.Client
Close() error
}
type HandlerInterface interface {