fix: ensure registry is setup in construction

This commit is contained in:
Derrick Hammer 2024-01-10 06:42:17 -05:00
parent 7578665ba4
commit 65727b8cc5
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 8 additions and 5 deletions

View File

@ -52,7 +52,7 @@ func NewNode(config *config.NodeConfig) interfaces.Node {
hashQueryRoutingTable: structs.NewMap(),
httpClient: resty.New(),
}
n.services = NewServices(service.NewP2P(n))
n.services = NewServices(service.NewP2P(n), service.NewRegistry(n))
return n
}

View File

@ -23,8 +23,11 @@ func (s *ServicesImpl) Registry() interfaces.RegistryService {
return s.registry
}
func NewServices(p2p interfaces.P2PService) *ServicesImpl {
return &ServicesImpl{p2p: p2p}
func NewServices(p2p interfaces.P2PService, registry interfaces.RegistryService) interfaces.Services {
return &ServicesImpl{
p2p: p2p,
registry: registry,
}
}
func (s *ServicesImpl) P2P() interfaces.P2PService {

View File

@ -44,10 +44,10 @@ func (r *RegistryImpl) Init() error {
return utils.CreateBucket(registryBucketName, r.node.Db())
}
func NewRegistry(node interfaces.Node, logger *zap.Logger) *RegistryImpl {
func NewRegistry(node interfaces.Node) *RegistryImpl {
return &RegistryImpl{
node: node,
logger: logger,
logger: node.Logger(),
streams: structs.NewMap(),
subs: structs.NewMap(),
}