Skip to content
Snippets Groups Projects
Verified Commit 45c20ff2 authored by André Sterba's avatar André Sterba
Browse files

Remove interfaces folder and migrate legacy storables

parent 007c481a
No related branches found
No related tags found
1 merge request!557Draft: Refactor nucleus to remove hard dependencies on structs
Pipeline #163464 failed
package store
package ports
import "github.com/google/uuid"
......
......@@ -5,7 +5,7 @@ import (
"sync"
"code.fbi.h-da.de/danet/gosdn/controller/customerrs"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/store"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/ports"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
......@@ -13,11 +13,11 @@ import (
// newGenericStore returns a genericStore.
func newGenericStore() *genericStore {
return &genericStore{Store: make(map[uuid.UUID]store.Storable), storeLock: sync.RWMutex{}}
return &genericStore{Store: make(map[uuid.UUID]ports.Storable), storeLock: sync.RWMutex{}}
}
type genericStore struct {
Store map[uuid.UUID]store.Storable
Store map[uuid.UUID]ports.Storable
storeLock sync.RWMutex
}
......@@ -30,7 +30,7 @@ func (s *genericStore) Exists(id uuid.UUID) bool {
}
// Add adds a Storable to the Store.
func (s *genericStore) Add(item store.Storable) error {
func (s *genericStore) Add(item ports.Storable) error {
if s.Exists(item.ID()) {
return &customerrs.AlreadyExistsError{Item: item}
}
......@@ -48,7 +48,7 @@ func (s *genericStore) Add(item store.Storable) error {
// Storable does not exist an error is returned. Get is only type safe for
// this Storable interface. For type safe get operations on specialised stores
// use GetDevice, GetPND, GetSBI, or GetChange respectively.
func (s *genericStore) Get(id uuid.UUID) (store.Storable, error) {
func (s *genericStore) Get(id uuid.UUID) (ports.Storable, error) {
if !s.Exists(id) {
return nil, &customerrs.CouldNotFindError{ID: id}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment