simplify storage inheritance

This commit is contained in:
Pascal Fischer 2024-03-14 11:42:25 +01:00
parent f31b06fc92
commit 27c3a4c5d6
9 changed files with 27 additions and 27 deletions

View File

@ -27,8 +27,8 @@ type DefaultController struct {
func NewDefaultController() *DefaultController {
storeStore, _ := store.NewDefaultStore(store.SqliteStoreEngine, "", nil)
peersManager := peers.NewDefaultManager(storeStore, nil)
settingsManager := settings.NewDefaultManager(storeStore)
peersManager := peers.NewDefaultManager(storeStore, settingsManager)
usersManager := users.NewDefaultManager(storeStore, peersManager)
policiesManager := policies.NewDefaultManager(storeStore, peersManager)
@ -60,7 +60,7 @@ func (c *DefaultController) LoginPeer(login peers.PeerLogin) {
}
}
account, err := pm.accountManager.GetAccount(peer.AccountID)
account, err := pm.accountManager.GetAccount(peer.GetAccountID())
if err != nil {
return nil, nil, err
}
@ -117,8 +117,8 @@ func (c *DefaultController) GetPeerNetworkMap(peerID, dnsDomain string) *Network
aclPeers, firewallRules := c.policiesManager.GetAccessiblePeersAndFirewallRules(peerID)
// exclude expired peers
var peersToConnect []*peers.Peer
var expiredPeers []*peers.Peer
var peersToConnect []peers.Peer
var expiredPeers []peers.Peer
accSettings, _ := c.settingsManager.GetSettings(peer.GetAccountID())
for _, p := range aclPeers {
expired, _ := p.LoginExpired(accSettings.GetPeerLoginExpiration())

View File

@ -12,11 +12,11 @@ type Manager interface {
}
type DefaultManager struct {
repository repository
repository Repository
settingsManager settings.Manager
}
func NewDefaultManager(repository repository, settingsManager settings.Manager) *DefaultManager {
func NewDefaultManager(repository Repository, settingsManager settings.Manager) *DefaultManager {
return &DefaultManager{
repository: repository,
settingsManager: settingsManager,

View File

@ -1,8 +1,8 @@
package peers
type repository interface {
FindPeerByPubKey(pubKey string) (*Peer, error)
FindPeerByID(id string) (*Peer, error)
FindAllPeersInAccount(id string) ([]*Peer, error)
type Repository interface {
FindPeerByPubKey(pubKey string) (Peer, error)
FindPeerByID(id string) (Peer, error)
FindAllPeersInAccount(id string) ([]Peer, error)
UpdatePeer(peer Peer) error
}

View File

@ -1,4 +1,4 @@
package policies
type repository interface {
type Repository interface {
}

View File

@ -1,5 +1,5 @@
package settings
type repository interface {
type Repository interface {
FindSettings(accountID string) (Settings, error)
}

View File

@ -12,22 +12,22 @@ const (
type DefaultPostgresStore struct {
}
func (s *DefaultPostgresStore) FindSettings(accountID string) (*settings.Settings, error) {
func (s *DefaultPostgresStore) FindSettings(accountID string) (settings.Settings, error) {
// TODO implement me
panic("implement me")
}
func (s *DefaultPostgresStore) FindPeerByPubKey(pubKey string) (*peers.Peer, error) {
func (s *DefaultPostgresStore) FindPeerByPubKey(pubKey string) (peers.Peer, error) {
// TODO implement me
panic("implement me")
}
func (s *DefaultPostgresStore) FindPeerByID(id string) (*peers.Peer, error) {
func (s *DefaultPostgresStore) FindPeerByID(id string) (peers.Peer, error) {
// TODO implement me
panic("implement me")
}
func (s *DefaultPostgresStore) FindAllPeersInAccount(id string) ([]*peers.Peer, error) {
func (s *DefaultPostgresStore) FindAllPeersInAccount(id string) ([]peers.Peer, error) {
// TODO implement me
panic("implement me")
}

View File

@ -31,22 +31,22 @@ type DefaultSqliteStore struct {
installationPK int
}
func (s *DefaultSqliteStore) FindSettings(accountID string) (*settings.Settings, error) {
func (s *DefaultSqliteStore) FindSettings(accountID string) (settings.Settings, error) {
// TODO implement me
panic("implement me")
}
func (s *DefaultSqliteStore) FindPeerByPubKey(pubKey string) (*peers.Peer, error) {
func (s *DefaultSqliteStore) FindPeerByPubKey(pubKey string) (peers.Peer, error) {
// TODO implement me
panic("implement me")
}
func (s *DefaultSqliteStore) FindPeerByID(id string) (*peers.Peer, error) {
func (s *DefaultSqliteStore) FindPeerByID(id string) (peers.Peer, error) {
// TODO implement me
panic("implement me")
}
func (s *DefaultSqliteStore) FindAllPeersInAccount(id string) ([]*peers.Peer, error) {
func (s *DefaultSqliteStore) FindAllPeersInAccount(id string) ([]peers.Peer, error) {
// TODO implement me
panic("implement me")
}

View File

@ -14,18 +14,18 @@ import (
type Store interface {
GetLicense() string
FindPeerByPubKey(pubKey string) (*peers.Peer, error)
FindPeerByID(id string) (*peers.Peer, error)
FindAllPeersInAccount(id string) ([]*peers.Peer, error)
FindPeerByPubKey(pubKey string) (peers.Peer, error)
FindPeerByID(id string) (peers.Peer, error)
FindAllPeersInAccount(id string) ([]peers.Peer, error)
UpdatePeer(peer peers.Peer) error
FindSettings(accountID string) (settings.Settings, error)
}
type DefaultStore interface {
GetLicense() string
FindPeerByPubKey(pubKey string) (*peers.Peer, error)
FindPeerByID(id string) (*peers.Peer, error)
FindAllPeersInAccount(id string) ([]*peers.Peer, error)
FindPeerByPubKey(pubKey string) (peers.Peer, error)
FindPeerByID(id string) (peers.Peer, error)
FindAllPeersInAccount(id string) ([]peers.Peer, error)
UpdatePeer(peer peers.Peer) error
FindSettings(accountID string) (settings.Settings, error)
}

View File

@ -1,4 +1,4 @@
package users
type repository interface {
type Repository interface {
}