Simplified the persistence backend a bit for now
This commit is contained in:
@@ -4,15 +4,14 @@ package sw
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/ESilva15/PTInvCertSWDB/config"
|
||||
models "github.com/ESilva15/PTInvCertSWDB/sw/models"
|
||||
repo "github.com/ESilva15/PTInvCertSWDB/sw/repo"
|
||||
)
|
||||
|
||||
type RepoType int
|
||||
|
||||
const (
|
||||
FILEDB RepoType = iota
|
||||
POSTGRES
|
||||
FILEDB = "YAML"
|
||||
POSTGRES = "PG"
|
||||
)
|
||||
|
||||
var service *SWService
|
||||
@@ -21,18 +20,20 @@ type SWService struct {
|
||||
SWRepo repo.SWRepo
|
||||
}
|
||||
|
||||
func StartSWService(rt RepoType) error {
|
||||
func StartSWService() error {
|
||||
cfg := config.GetInstance()
|
||||
|
||||
var err error
|
||||
var swRepo repo.SWRepo
|
||||
|
||||
switch rt {
|
||||
switch cfg.DataBackend {
|
||||
case FILEDB:
|
||||
swRepo, err = repo.NewYAMLRepo("./swdb.yaml")
|
||||
swRepo, err = repo.NewYAMLRepo(cfg.YamlBackend.Path)
|
||||
if err != nil {
|
||||
return errors.New("Failed to create yaml repo: " + err.Error())
|
||||
}
|
||||
default:
|
||||
return errors.New("repo type not implemented yet")
|
||||
return errors.New("chosen persistence backend not implemented yet")
|
||||
}
|
||||
|
||||
service = &SWService{
|
||||
|
||||
Reference in New Issue
Block a user