From 9919ad72da16dcc95a36eedacc6e3e36860aa2b8 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 30 Jan 2024 15:46:00 -0500 Subject: [PATCH] fix: add init to services and node --- node/node.go | 4 ++++ node/services.go | 11 +++++++++++ service/service.go | 1 + 3 files changed, 16 insertions(+) diff --git a/node/node.go b/node/node.go index e48afb6..4025ff6 100644 --- a/node/node.go +++ b/node/node.go @@ -55,6 +55,10 @@ func (n *Node) Start() error { return n.services.Start() } +func (n *Node) Init() error { + return n.services.Init() +} + func (n *Node) Stop() error { return n.services.Stop() } diff --git a/node/services.go b/node/services.go index 8b31197..83b5f31 100644 --- a/node/services.go +++ b/node/services.go @@ -69,6 +69,17 @@ func (s *ServicesImpl) IsStarted() bool { return s.started } +func (s *ServicesImpl) Init() error { + for _, svc := range s.All() { + err := svc.Init() + if err != nil { + return err + } + } + + return nil +} + func (s *ServicesImpl) Start() error { for _, svc := range s.All() { err := svc.Start() diff --git a/service/service.go b/service/service.go index 10d4b59..a902742 100644 --- a/service/service.go +++ b/service/service.go @@ -21,6 +21,7 @@ type Services interface { HTTP() HTTPService Storage() StorageService All() []Service + Init() error IsStarted() bool Start() error Stop() error