fix: ensure registry is setup in construction
This commit is contained in:
parent
7578665ba4
commit
65727b8cc5
|
@ -52,7 +52,7 @@ func NewNode(config *config.NodeConfig) interfaces.Node {
|
||||||
hashQueryRoutingTable: structs.NewMap(),
|
hashQueryRoutingTable: structs.NewMap(),
|
||||||
httpClient: resty.New(),
|
httpClient: resty.New(),
|
||||||
}
|
}
|
||||||
n.services = NewServices(service.NewP2P(n))
|
n.services = NewServices(service.NewP2P(n), service.NewRegistry(n))
|
||||||
|
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,11 @@ func (s *ServicesImpl) Registry() interfaces.RegistryService {
|
||||||
return s.registry
|
return s.registry
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServices(p2p interfaces.P2PService) *ServicesImpl {
|
func NewServices(p2p interfaces.P2PService, registry interfaces.RegistryService) interfaces.Services {
|
||||||
return &ServicesImpl{p2p: p2p}
|
return &ServicesImpl{
|
||||||
|
p2p: p2p,
|
||||||
|
registry: registry,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServicesImpl) P2P() interfaces.P2PService {
|
func (s *ServicesImpl) P2P() interfaces.P2PService {
|
||||||
|
|
|
@ -44,10 +44,10 @@ func (r *RegistryImpl) Init() error {
|
||||||
return utils.CreateBucket(registryBucketName, r.node.Db())
|
return utils.CreateBucket(registryBucketName, r.node.Db())
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRegistry(node interfaces.Node, logger *zap.Logger) *RegistryImpl {
|
func NewRegistry(node interfaces.Node) *RegistryImpl {
|
||||||
return &RegistryImpl{
|
return &RegistryImpl{
|
||||||
node: node,
|
node: node,
|
||||||
logger: logger,
|
logger: node.Logger(),
|
||||||
streams: structs.NewMap(),
|
streams: structs.NewMap(),
|
||||||
subs: structs.NewMap(),
|
subs: structs.NewMap(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue