fix: break import cycle
This commit is contained in:
parent
66e1cba39b
commit
2040d4edbc
|
@ -19,7 +19,7 @@ var (
|
||||||
|
|
||||||
type PortalImpl struct {
|
type PortalImpl struct {
|
||||||
apiRegistry interfaces.APIRegistry
|
apiRegistry interfaces.APIRegistry
|
||||||
protocolRegistry protocols.ProtocolRegistry
|
protocolRegistry interfaces.ProtocolRegistry
|
||||||
logger *zap.Logger
|
logger *zap.Logger
|
||||||
identity ed25519.PrivateKey
|
identity ed25519.PrivateKey
|
||||||
storage interfaces.StorageService
|
storage interfaces.StorageService
|
||||||
|
@ -86,6 +86,6 @@ func (p *PortalImpl) SetIdentity(identity ed25519.PrivateKey) {
|
||||||
func (p *PortalImpl) SetLogger(logger *zap.Logger) {
|
func (p *PortalImpl) SetLogger(logger *zap.Logger) {
|
||||||
p.logger = logger
|
p.logger = logger
|
||||||
}
|
}
|
||||||
func (p *PortalImpl) ProtocolRegistry() protocols.ProtocolRegistry {
|
func (p *PortalImpl) ProtocolRegistry() interfaces.ProtocolRegistry {
|
||||||
return p.protocolRegistry
|
return p.protocolRegistry
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package interfaces
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
"git.lumeweb.com/LumeWeb/portal/protocols"
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -15,7 +14,7 @@ type Portal interface {
|
||||||
Logger() *zap.Logger
|
Logger() *zap.Logger
|
||||||
Db() *gorm.DB
|
Db() *gorm.DB
|
||||||
ApiRegistry() APIRegistry
|
ApiRegistry() APIRegistry
|
||||||
ProtocolRegistry() protocols.ProtocolRegistry
|
ProtocolRegistry() ProtocolRegistry
|
||||||
Identity() ed25519.PrivateKey
|
Identity() ed25519.PrivateKey
|
||||||
Storage() StorageService
|
Storage() StorageService
|
||||||
SetIdentity(identity ed25519.PrivateKey)
|
SetIdentity(identity ed25519.PrivateKey)
|
||||||
|
|
|
@ -4,3 +4,9 @@ type Protocol interface {
|
||||||
Initialize(portal Portal) error
|
Initialize(portal Portal) error
|
||||||
Start() error
|
Start() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ProtocolRegistry interface {
|
||||||
|
Register(name string, protocol Protocol)
|
||||||
|
Get(name string) (Protocol, error)
|
||||||
|
All() map[string]Protocol
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package protocols
|
package protocols
|
||||||
|
|
||||||
func Init(registry ProtocolRegistry) error {
|
import "git.lumeweb.com/LumeWeb/portal/interfaces"
|
||||||
|
|
||||||
|
func Init(registry interfaces.ProtocolRegistry) error {
|
||||||
registry.Register("s5", NewS5Protocol())
|
registry.Register("s5", NewS5Protocol())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,20 +6,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ ProtocolRegistry = (*ProtocolRegistryImpl)(nil)
|
_ interfaces.ProtocolRegistry = (*ProtocolRegistryImpl)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProtocolRegistry interface {
|
|
||||||
Register(name string, protocol interfaces.Protocol)
|
|
||||||
Get(name string) (interfaces.Protocol, error)
|
|
||||||
All() map[string]interfaces.Protocol
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProtocolRegistryImpl struct {
|
type ProtocolRegistryImpl struct {
|
||||||
protocols map[string]interfaces.Protocol
|
protocols map[string]interfaces.Protocol
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProtocolRegistry() ProtocolRegistry {
|
func NewProtocolRegistry() interfaces.ProtocolRegistry {
|
||||||
return &ProtocolRegistryImpl{
|
return &ProtocolRegistryImpl{
|
||||||
protocols: make(map[string]interfaces.Protocol),
|
protocols: make(map[string]interfaces.Protocol),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue