From 65727b8cc553c62a3aa62a6fd9735b171dccb1e2 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 10 Jan 2024 06:42:17 -0500 Subject: [PATCH] fix: ensure registry is setup in construction --- node/node.go | 2 +- node/services.go | 7 +++++-- service/registry.go | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/node/node.go b/node/node.go index 2e3c5d8..a608bb1 100644 --- a/node/node.go +++ b/node/node.go @@ -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 } diff --git a/node/services.go b/node/services.go index 8d84e4c..64b09ba 100644 --- a/node/services.go +++ b/node/services.go @@ -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 { diff --git a/service/registry.go b/service/registry.go index 707123e..f98a161 100644 --- a/service/registry.go +++ b/service/registry.go @@ -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(), }