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
This commit is part of merge request !557. Comments created here will be created in the context of that merge request.
package store package ports
import "github.com/google/uuid" import "github.com/google/uuid"
......
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"sync" "sync"
"code.fbi.h-da.de/danet/gosdn/controller/customerrs" "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" "github.com/google/uuid"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
...@@ -13,11 +13,11 @@ import ( ...@@ -13,11 +13,11 @@ import (
// newGenericStore returns a genericStore. // newGenericStore returns a genericStore.
func newGenericStore() *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 { type genericStore struct {
Store map[uuid.UUID]store.Storable Store map[uuid.UUID]ports.Storable
storeLock sync.RWMutex storeLock sync.RWMutex
} }
...@@ -30,7 +30,7 @@ func (s *genericStore) Exists(id uuid.UUID) bool { ...@@ -30,7 +30,7 @@ func (s *genericStore) Exists(id uuid.UUID) bool {
} }
// Add adds a Storable to the Store. // 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()) { if s.Exists(item.ID()) {
return &customerrs.AlreadyExistsError{Item: item} return &customerrs.AlreadyExistsError{Item: item}
} }
...@@ -48,7 +48,7 @@ func (s *genericStore) Add(item store.Storable) error { ...@@ -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 // 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 // this Storable interface. For type safe get operations on specialised stores
// use GetDevice, GetPND, GetSBI, or GetChange respectively. // 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) { if !s.Exists(id) {
return nil, &customerrs.CouldNotFindError{ID: 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